AccountsApp

This is the top-level object used in multi-account scripts to get the list of accounts the user has access to and to select the account to manage. After getting the account, use the AdsApp object to access its entities.

This object is available for scripts run from the Scripts editor accessed from Accounts Summary in the Microsoft Advertising web application.

Methods

Method Name Return Type Description
accounts BingAdsAccountSelector Gets a selector used to filter the list of accounts the user has access to.
select(BingAdsAccount account) void Selects the account to process in the script.

accounts

Gets a selector used to filter the list of accounts the user has access to.

Returns

Type Description
BingAdsAccountSelector A selector used to filter the list of accounts the user has access to.

select(BingAdsAccount account)

Selects the account to process in the script.

The following example shows how to change the current account that the script is processing with another account.

    // Get the account that the script is currently processing.
    var oldAccount = AdsApp.currentAccount();

    // Get another account that the user manages.
    var newAccount = AccountsApp.accounts()
        .withIds(["123456789"])
        .get()
        .next();

    // Make the new account the current account that the script processes.
    AccountsApp.select(newAccount);

    // Do something with the new account

    // Change the current account back to the old account
    AccountsApp.select(oldAccount);

Arguments

Name Type Description
account BingAdsAccount The account to process in the script.

Returns

Type Description
void Returns nothing.

See also

Multi-account access