我正在尝试修改此脚本,当我手动更改A中的任何内容时,它会起作用,但我希望脚本在A中的单元格内容从公式I更改之前触发有(importXML)从另一个站点提取数据。它只是一个工作表,只有一个importxml函数。
function sendNotification() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var cell = ss.getActiveCell().getA1Notation();
var row = sheet.getActiveRange().getRow();
var cellvalue = ss.getActiveCell().getValue().toString();
var recipients = "@gmail.com";
var message = '';
if(cell.indexOf('A')!=-1){
message = sheet.getRange('A'+ sheet.getActiveCell().getRowIndex()).getValue();
}
var subject = 'Update to '+sheet.getName();
var body = sheet.getName() + ' has been updated. Visit ' + ss.getUrl() + ' to view the changes on row: «' + row + '». New comment: «' + cellvalue + '». For message: «' + message + '»';
MailApp.sendEmail(recipients, subject, body);
}
答案 0 :(得分:0)
我假设您的触发功能是“发送通知”,
function sendNotification(event) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var recipients = "reciever@gmail.com";
var message = '';
var range = event.range;
if ( (range.getColumn() == 1) && (event.value != event.oldValue)) {
message = event.value;
var subject = 'Update to '+sheet.getName();
var body = sheet.getName() + ' has been updated. Visit ' + ss.getUrl() + ' to view the changes on row: «' + range.getRow() + '». New comment: «' + event.value + '». For message: «' + message + '»';
MailApp.sendEmail(recipients, subject, body);
}
}
另外,您可能需要手动配置触发器,
享受