Execution info
Stay organized with collections
Save and categorize content based on your preferences.
Information about a running script
You can access certain attributes of a running script through the methods of
the
ExecutionInfo
object. For example,
isPreview()
tells you whether a script is currently being previewed or is actually
executing.
This often simplifies debugging code:
// 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);
}
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:
let accountId = AdsApp.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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-01-28 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-28 UTC."],[[["Access attributes of a running script using the `ExecutionInfo` object, such as determining if the script is in preview mode with `isPreview()`."],["Utilize the `Account` object to retrieve account information like customer ID (`getCustomerId()`), currency, and time zone, particularly useful when a single script operates across multiple accounts."],["Simplify debugging and reporting by conditionally executing code based on the script's execution mode and including account-specific details in outputs like emails."]]],[]]