【发布时间】:2017-07-21 17:23:16
【问题描述】:
我希望在用户创建包含来自该条目(或小部件)的信息的条目时发送一封通知电子邮件。
例如:
至:groupemail@company.com
主题:项目名称
body:“用户 1 创建了一个状态为进行中的新项目”。
我试图查看 Project Tracker App 以供参考,但我还是迷路了。
我假设我需要创建一个客户端脚本,执行类似下面的函数并将该函数添加到页面片段中“提交按钮”的 onClick 事件以创建新条目,但它不起作用。
提交按钮 onClick 事件:
widget.datasource.createItem();
sendEmailCreated_(to, subject, body);
app.closeDialog();
客户端脚本:
function sendEmailCreated_(to, subject, body) {
var widgets = widget.root.descendants;
try {
MailApp.sendEmail({
to: 'groupemail@company.com',
subject: widgets.ProjectName.value,
body: 'User1 has created a new project with the Status of' + widgets.ProjectStatus.value,
noReply: true
});
} catch (e) {
// Suppressing errors in email sending because email notifications
// are not critical for the functioning of the app.
console.error(JSON.stringify(e));
}
}
当函数尝试运行时,它说“to”是未定义的,我确定我没有为“widgets.ProjectName.value”之类的东西使用正确的选项。
任何帮助将不胜感激。
谢谢。
【问题讨论】:
标签: google-app-maker