0
私の例sheet。セルのifステートメントの返信に基づいて電子メールを送信します。
列Dのセルが「勝者」である場合、recipient1に電子メールを送信します。また、列Eのセルが「勝者」である場合、recipient2に電子メールを送信したいと思います。私のスクリプトは、列DまたはEの任意のセルに "WINNER"を手動で入力すると機能しますが、if文の結果としてセルが "WINNER"に変更されたときには機能しません。私はスクリプトを "WINNER"の代わりにtrueに変更しようとしましたが、それもうまくいきませんでした。
/**
* add trigger for onedit -
* see menu -> Resouces -> Current project's triggers
*/
function Initialize() {
var triggers = ScriptApp.getProjectTriggers();
for(var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
ScriptApp.newTrigger("sendNotification")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onEdit()
.create();
ScriptApp.newTrigger("sendNotification2")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onEdit()
.create();
};
/**
*
*/
function sendNotification(f) {
if("D" == f.range.getA1Notation().charAt(0)) {
if(f.value == "WINNER") {
//Define Notification Details
var recipients = "[email protected]";
var subject = "Update"+f.range.getSheet().getName();
var body = "Adam just won the lottery!";
//Send the Email
MailApp.sendEmail(recipients, subject, body);
}
}
}
function sendNotification2(f) {
if("E" == f.range.getA1Notation().charAt(0)) {
if(f.value == "WINNER") {
//Define Notification Details
var recipients = "[email protected]";
var subject = "Update"+f.range.getSheet().getName();
var body = "Geo just won the lottery!";
//Send the Email
MailApp.sendEmail(recipients, subject, body);
}
}
}
私が読んで覚えているものは、実際に編集でトリガが、私は今のドキュメントを見つけることができませんかについて。あなたは直接あなたにsendNotification関数をトリガーするifロジックを変更しようとしましたか? –