关于正在运行的脚本的信息
您可以通过
该
ExecutionInfo
对象。例如:
isPreview()
会告知您脚本当前是处于预览状态,还是
代码。
这通常可以简化调试代码:
// Code that generates a report.
// ...
if (!AdsApp.getExecutionInfo().isPreview()) {
// Do not email the report when in preview mode!
MailApp.sendEmail("customer@example.com", "Report is ready!", report);
}
关于脚本账户的信息
通常需要有正在运行的脚本的账号信息,尤其是在
多个账号使用同一个未更改的脚本。如果脚本
接收方需要识别源账号。您可以
使用
Account
对象的
getCustomerId()
方法:
let accountId = AdsApp.currentAccount().getCustomerId();
MailApp.sendEmail("customer@example.com",
"Report is ready for " + accountId, report);
Account
对象还提供一些方法,可让您识别账号的
币种和时区。