How to query across accounts with this account hierarchy.
Hello. I am trying to write a script that will allow my company to record stats across the hundreds of Microsoft Ads accounts that we manage on our clients' behalf.
We have an unusual account structure/hierarchy that seems to render the existing single-account and multi-account access documentation unhelpful. No matter what I try, I cannot select any account other than the direct child account that is associated with our organization. Below is but one of the scripts I have written to try to access the broader account hierarchy. Finally, I have attached a screenshot of the account hierarchy as it appears in the Accounts Summary of the parent manager account.
Any help in the right direction will be very useful. Thanks so much!
function main() {
Logger.log("Script started");
// Fetch the accounts linked to the current manager account
var accounts = AccountsApp.accounts().get();
while (accounts.hasNext()) {
var account = accounts.next();
Logger.log("Found Account: " + account.getName() + " (" + account.getAccountId() + ")");
// Process further based on your requirements
}
}
main();