function main() {
var sheets = spreadsheet.getSheets();
var rows = [];
if (sheets.length >= 1) {
for (var i=0;i<sheets.length;i++) {
var sheet=sheets[i];
var sheetName = sheet.getName();
var accountId = sheetName.match(patternCID);
if(accountId && patternCID.test(accountId[0])) {
rows.push(accountId[0]);
}
}
}
startProcess(rows)
}
function startProcess(accountsId) {
try {
var accounts = AdsManagerApp.accounts().withIds(accountsId);
accounts.executeInParallel("processAccount", "allFinished"); //this allow the script works for 60mn total
} catch (e) {
Logger.log(e)
}
}
var accounts = AdsManagerApp.accounts().withIds(accountsId);Hi Yoann,
You should be able to query the client accounts belonging to a specific sub manager through the use of the AdsManagerApp.ManagedAccountSelector, wherein you can use the withCondition() and use the ManagedCustomerId column. You can then specify the ID of the sub manager as the condition.
As for your second question, you would need to implement something similar to the above for retrieving the client accounts of a sub manager and then query the campaign information for each of the customer accounts that were returned. For more information on the possible ways to query campaigns, you may refer to this guide.
Let me know if this works on your end.
Thanks,
Peter
Google Ads Scripts Team