Hi Sam,
Thank you for reaching out to the Google Ads Scripts Forum Channel.
Kindly note that you would need to implement the script inside a main function or call this function (selectAccountsByLabelResourceName) within the main function. Upon testing the content of your script on my end, I was able to retrieve an account a label was applied to:
function main() { var query = "customer_client.applied_labels CONTAINS ANY ('customers/8xxxxxxxxx/labels/4xxxxxxxxx')"; let accountIterator = AdsManagerApp.accounts() .withCondition(query) .get(); for (const account of accountIterator) { const accountName = account.getName() ? account.getName() : '--'; console.log('123:: %s,%s,%s,%s', account.getCustomerId(), accountName); } }
Kindly try this on your end and let us know how it goes. If you'd still encounter any issues, please provide your Google Ads account ID as well as the name of this script so that we may be able to further investigate.
Google Ads Scripts Team |