Execution Info

Information about a running script

You can access certain attributes of a running script through the methods of the ExecutionInfo object. isPreview(), for instance, tells you whether a script is currently being previewed or is actually executing. This often simplifies debugging code:

// Code that generates a report.
// ...
if (!AdWordsApp.getExecutionInfo().isPreview()) {
  // Do not email the report when in preview mode!
  MailApp.sendEmail("customer@example.com", "Report is ready!", report);
}

Additionally, the ExecutionInfo object exposes remaining quota, allowing a script to make intelligent decisions when nearing its limits.

Information about a script's account

Account information for a running script is often needed, especially when the same unchanged script is used in multiple accounts. If the script is emailing out a report, the recipient needs to identify the originating account. You can use the Account object's getCustomerId() method for this:

var accountId = AdWordsApp.currentAccount().getCustomerId();
MailApp.sendEmail("customer@example.com",
    "Report is ready for " + accountId, report);

The Account object also has methods to let you identify the account's currency and time zone.

Send feedback about...

AdWords Scripts
AdWords Scripts
Need help? Visit our support page.