我想知道,Google电子表格中的以下内容如何。
嗨Serge,
尝试实现您提供的代码,但我无法对要修改的内容做出正面或反面,以适应我的需要。
让我用下面的工作流程再次解释一下。
当K列的值发生变化时发送电子邮件。
观看专栏K的部分示例代码
var sheetNameToWatch = "Active Discs";
var columnNumberToWatch = 14; // column A = 1, B = 2, etc.
var valueToWatch1 = "Completed";
var valueToWatch2 = "in progress";
try{
var ss = e.source;
var sheet = ss.getActiveSheet();
var range = e.range;
if (sheet.getName() == sheetNameToWatch && range.columnStart ==
columnNumberToWatch && e.value == valueToWatch)
var confirm = Browser.msgBox
('Email will be sent Team X. Do you want to sent this email?', Browser.Buttons.YES_NO);
if(confirm!='yes'){return};
// if user click NO then exit the function, else move data
电子邮件将包含该特定行的指定值。防爆。 A,B,C,D,E,F,G,H,I,J列中的值。
//Email to be sent if **Inprogess** value is a match:
Var sendEmailTeamA(){
var ProjectName = e.values[0];
var ProjectId = e.values[1];
var ProjectManager = e.values[3];
var Sales = e.values[4];
var Client = e.values[5];
var DiscType = e.values[6];
var DVDFlash = e.values[7];
var Phase = e.values[8];
var Encryption = e.values[9];
var Qty = e.values[11];
var DueDate = e.values[12];
var SpecialInstructions = e.values[13];
var emailAddress = '';
var subject = "DVD Request - " + ProjectName + " " + ProjectId;
var emailBody = "Hi Venue Colombo Team,"
"\n\nThe following data room(s) will need a disc creation. Please begin bulk save data room and create ISO to upload to the FTP site: " +
"\nProject Name: " + ProjectName +
"\nProject ID: " + ProjectId +
"\nProject Manager: " + ProjectManager +
"\nPhase: " + Phase +
"\nDisc Type: " + DiscType +
"\nEncryption: " + Encryption +
"\nQuantity: " + Qty +
"\nClient Due Date: " + DueDate +
"\nSpecialInstructions: " + SpecialInstructions;
var htmlBody = "Thank you for your <b>Club Ambassador Program</b> report submitted on <i>" + timestamp +
"</i><br/> <br/>Person Show Submitted this email: " +
"<br/><font color=\"red\">Your Name:</font> " + activeSessionuser +
"<br/>Your Email: " + toAddress;
var optAdvancedArgs = {name: "Club Ambassador Program", htmlBody: htmlBody};
MailApp.sendEmail(emailAddress, subject, emailBody, optAdvancedArgs);
}
//Email to be sent if **“Completed”** value is a match:
Var sendEmailTeamB() {
var ProjectName = e.values[0];
var ProjectId = e.values[1];
var ProjectManager = e.values[3];
var Sales = e.values[4];
var Client = e.values[5];
var DiscType = e.values[6];
var DVDFlash = e.values[7];
var Phase = e.values[8];
var Encryption = e.values[9];
var Qty = e.values[11];
var DueDate = e.values[12];
var SpecialInstructions = e.values[13];
var emailAddress = '';
var subject = "DVD Request - " + ProjectName + " " + ProjectId;
var emailBody = "Hi Venue Colombo Team,"
"\n\nThe following data room(s) will need a disc creation. Please begin bulk save data room and create ISO to upload to the FTP site: " +
"\nProject Name: " + ProjectName +
"\nProject ID: " + ProjectId +
"\nProject Manager: " + ProjectManager +
"\nPhase: " + Phase +
"\nDisc Type: " + DiscType +
"\nEncryption: " + Encryption +
"\nQuantity: " + Qty +
"\nClient Due Date: " + DueDate +
"\nSpecialInstructions: " + SpecialInstructions;
var htmlBody = "Thank you for your <b>Club Ambassador Program</b> report submitted on <i>" + timestamp +
"</i><br/> <br/>Person Show Submitted this email: " +
"<br/><font color=\"red\">Your Name:</font> " + activeSessionuser +
"<br/>Your Email: " + toAddress;
var optAdvancedArgs = {name: "Club Ambassador Program", htmlBody: htmlBody};
MailApp.sendEmail(emailAddress, subject, emailBody, optAdvancedArgs);
}
此工作流程将应用于列K,L,M,N,O。电子邮件将发送到代码中的预设电子邮件地址。我希望这能更好地解释它。我再次感谢你的时间和帮助。
答案 0 :(得分:1)
我可以帮助你开始:
答案 1 :(得分:1)
我刚刚编写了一个脚本来做这种事情,但我希望它能够密切关注工作表中的所有更改,但每小时只发送一次消息,以避免发送垃圾邮件。
该脚本有两个功能,一个用于收集更改并以文本格式存储它们,另一个用于在最后一小时内发生任何更改时发送电子邮件。
第一个函数叫做grabData,必须由onEdit可安装触发器触发,如下所示:
function grabData(e){
Logger.log(JSON.stringify(e));
var cell = e.range.getA1Notation();
var user = e.user.email;
var time = Utilities.formatDate(new Date(),Session.getScriptTimeZone(),'dd-MM-yyyy')+' à '+Utilities.formatDate(new Date(),Session.getScriptTimeZone(),'hh:mm');;
if(user!='email1@email.com'&&cell!='A1'){
var dataUser1 = PropertiesService.getScriptProperties().getProperty('contentUser1');
if(dataUser1==null){dataUser1=''};
dataUser1+='\nCellule '+cell+' modifiée le '+time+' par '+user+' (nouvelle valeur = '+e.range.getValue()+')';
PropertiesService.getScriptProperties().setProperty('contentUser1',dataUser1);
}
if(user!='email2@email.com'&&cell!='A1'){
var dataUser2 = PropertiesService.getScriptProperties().getProperty('contentUser2');
if(dataUser2==null){dataUser2=''};
dataUser2+='\nCellule '+cell+' modifiée le '+time+' par '+user+' (nouvelle valeur = '+e.range.getValue()+')';
PropertiesService.getScriptProperties().setProperty('contentUser2',dataUser2);
}
}
另一个功能有一个定时器触发器,我将它设置为每小时触发一次,但你可以将其改为最佳状态。
function sendReport(){
var dataUser1 = PropertiesService.getScriptProperties().getProperty('contentUser1');
var dataUser2 = PropertiesService.getScriptProperties().getProperty('contentUser2');
if(dataUser1.length>1){
MailApp.sendEmail('email2@email.com', 'Modification dans le planning FFE', dataUser1);
PropertiesService.getScriptProperties().setProperty('contentUser1','');
}
if(dataUser2.length>1){
MailApp.sendEmail('email1@email.com', 'Modification dans le planning FFE', dataUser2);
PropertiesService.getScriptProperties().setProperty('contentUser2','');
}
}
发送邮件后,将删除存储的数据。如果未记录任何更改,则不会发送邮件。
您还可以注意到,我有2个不同的用户和2个不同的存储位置,这样每个用户都可以看到对方做了什么而没有得到他自己修改的通知。
由于这两个功能都使用可安装的触发器,因此这将在您的帐户上运行,因此如果您将计时器设置为非常短的时间段,请注意不要爆炸您的配额。