如何解决Google Sheets Mobile的自动电子邮件功能
我正在尝试运行由Lauren Script for Google sheets (auto email function)共享的出色脚本,并遇到问题。我在stackoverflow上还很陌生,所以让我知道是否需要以其他方式询问这个问题,是否违反了任何规范?我已经设置并成功编辑了此脚本以执行我需要的操作。我有一个团队将在移动设备上使用它。我尝试过,但没有成功!您能帮我或指出正确的方向吗?
这是针对任务列表的,当某人随后选择一个复选框时,它将向团队负责人发送任何添加的注释和详细信息(然后根据脚本取消选中该复选框)。该复选框很棒,因为每行有一个。但欢迎任何建议
很抱歉,您所提供的信息不够清晰,感谢@TheMaster在这里提供的帮助。代码在下面,但听起来我正在尝试做不可能的事情?以为我可以用Google表格完成此操作,但似乎在android ap上是不可能的。我不是很先进,可能需要放弃该项目!甚至有任何建议甚至可以通过其他方法来做到这一点?
function EmailNotification(e) {
var ui = SpreadsheetApp.getUi();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Deliveries'); //source sheet
var columnb = sheet.getRange('J:J'); //Column with check boxes
var columnbvalue = columnb.getValues();
var notifysheet = ss.getSheetByName('Responses'); //destination sheet
var data = [];
var rownum =[];
//Condition check in B:B (or check box column); If true copy the same row to data array
for (i=0; i<columnbvalue.length;i++) {
if (columnbvalue[i] == 'true') {
var columnb2 = sheet.getRange('J2:J');
columnb2.setValue('false');
// What you want to say in the pop up alert
var response = ui.alert('Hold Up!\n Are you sure you want to send an email to team leaders for this delivery?',ui.ButtonSet.YES_NO);
if (response == ui.Button.YES) {
data.push.apply(data,sheet.getRange(i+1,1,20).getValues());
//Copy matched ROW numbers to rownum
rownum.push(i);
//Copy data array to destination sheet
notifysheet.getRange(notifysheet.getLastRow()+1,data.length,data[0].length).setValues(data);
var activeRow = notifysheet.getLastRow();
var suppliername = notifysheet.getRange(activeRow,1).getDisplayValue(); // The number is the column number in the destination "responses" sheet that you want to include in the email
var owner = notifysheet.getRange(activeRow,3).getDisplayValue();
var recievedby = notifysheet.getRange(activeRow,8).getDisplayValue();
var instructions = notifysheet.getRange(activeRow,5).getDisplayValue();
var status = notifysheet.getRange(activeRow,7).getDisplayValue();
var notes = notifysheet.getRange(activeRow,9).getDisplayValue();
var email = notifysheet.getRange(activeRow,4).getDisplayValue();
var subject = 'Delivery completed!'
//Body of the email message,using HTML and the variables from above
var message =
'<br><br><div style="margin-left:40px;">Hello '+ owner +'</div>'
+'<br><br><div style="margin-left:40px;">A delivery you requested has been fulfilled</div>'
+'<br><br><div style="margin-left:40px;"><h3 style="text-decoration: underline;">Recieved Name: '+ recievedby +'</h3></div>'
+'<div style="margin-left:40px;">Supplier: '+ suppliername +'</div>'
+'<div style="margin-left:40px;">Special instructions you added: '+ instructions +'</div>'
+'<div style="margin-left:40px;">Status: '+ status +'</div>'
+'<div style="margin-left:40px;">Notes: '+ notes +'</div>'
+ '<br><br><div style="margin-left:40px;">ヽ(⌐■_■)ノI Did It ♪♬</div>';
MailApp.sendEmail(
email,subject,"",{
htmlBody: message,name: 'Shop Alerts',//The name you want to email coming from
});
}
}
}
}
解决方法
移动应用程序不支持ui
或警报。您只需要删除它们即可。
function EmailNotification(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Deliveries'); //source sheet
var columnb = sheet.getRange('J:J'); //Column with check boxes
var columnbvalue = columnb.getValues();
var notifysheet = ss.getSheetByName('Responses'); //destination sheet
var data = [];
var rownum = [];
//Condition check in B:B (or check box column); If true copy the same row to data array
for (let i = 0; i < columnbvalue.length; i++) {
if (columnbvalue[i][0] === true) {
//modified to strict equality
var columnb2 = sheet.getRange('J2:J');
columnb2.setValue('false');
data.push.apply(data,sheet.getRange(i + 1,1,20).getValues());
//Copy matched ROW numbers to rownum
rownum.push(i);
//Copy data array to destination sheet
notifysheet
.getRange(notifysheet.getLastRow() + 1,data.length,data[0].length)
.setValues(data);
var activeRow = notifysheet.getLastRow();
var suppliername = notifysheet.getRange(activeRow,1).getDisplayValue(); // The number is the column number in the destination "responses" sheet that you want to include in the email
var owner = notifysheet.getRange(activeRow,3).getDisplayValue();
var recievedby = notifysheet.getRange(activeRow,8).getDisplayValue();
var instructions = notifysheet.getRange(activeRow,5).getDisplayValue();
var status = notifysheet.getRange(activeRow,7).getDisplayValue();
var notes = notifysheet.getRange(activeRow,9).getDisplayValue();
var email = notifysheet.getRange(activeRow,4).getDisplayValue();
var subject = 'Delivery completed!';
//Body of the email message,using HTML and the variables from above
var message =
'<br><br><div style="margin-left:40px;">Hello ' +
owner +
'</div>' +
'<br><br><div style="margin-left:40px;">A delivery you requested has been fulfilled</div>' +
'<br><br><div style="margin-left:40px;"><h3 style="text-decoration: underline;">Recieved Name: ' +
recievedby +
'</h3></div>' +
'<div style="margin-left:40px;">Supplier: ' +
suppliername +
'</div>' +
'<div style="margin-left:40px;">Special instructions you added: ' +
instructions +
'</div>' +
'<div style="margin-left:40px;">Status: ' +
status +
'</div>' +
'<div style="margin-left:40px;">Notes: ' +
notes +
'</div>' +
'<br><br><div style="margin-left:40px;">ヽ(⌐■_■)ノI Did It ♪♬</div>';
MailApp.sendEmail(email,subject,'',{
htmlBody: message,name: 'Shop Alerts',//The name you want to email coming from
});
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。