Google スプレッドシートの指定した行のみが更新された場合にGmailでNotification を受け取りたいと思っています。
以下のコードで実行できるかと試したところ、
「TypeError: オブジェクト Range で関数 getA11Notation が見つかりません」
と出てきました。このコードで間違いはありますか?
'スプレッドシートの名前';
function sendNotification() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName("シートの名前");
const cell = ss.getActiveCell().getA11Notation();
const columnNameInAlphabet = cell.replace(/\d+/,'');
//通知対象者と対応するメール通知先を連想配列で格納
const recipients = {
'宛先名':'メールアドレス'
};
//更新行のA列の値を取得
const person = sheet.getRange('A'+ sheet.getActiveCell().getRowIndex()).getValue();
//メールの件名と本文を指定
const subject = '【更新】'+ss.getName();
const body = person + 'の行が更新されました。\n' + ss.getUrl() + '\n更新対象は' + columnNameInAlphabet +'列です。';
//更新された行が通知対象の行を含む場合はメールを送る
if (person in recipients == true){
MailApp.sendEmail(recipients[person], subject, body);
}
};
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。