How do I stop the MccApp.accounts().get() from returning accounts in specified sub-MCC's?

581 views
Skip to first unread message

AussieWeb Conversion

unread,
Dec 4, 2014, 2:06:13 AM12/4/14
to adwords...@googlegroups.com
I have this code to generate my list of accounts to check.
var accountIter = MccApp.accounts()
 
.withCondition("ManagerCustomerId IN ['123-456-7890']")  //NB All sub-MCC's are included due heirarchy
 
.withCondition("ManagerCustomerId NOT_IN ['987-654-3210', '444-555-6666', '111-222-3333']") // Attempt to exclude sub-MCC's
 
.withLimit(50)
 
.get();

However, the list of accounts returned still contains those within the sub-MCC's.  It looks like the NOT_IN is being ignored.

I've even tried listing them one by one to no avail.
  .withCondition("ManagerCustomerId != '987-654-3210'")
 
.withCondition("ManagerCustomerId != '444-555-6666'")
 
.withCondition("ManagerCustomerId != '111-222-3333'")

How do I generate the list of accounts solely within one MCC and not within any of the specified child sub-MCC's?
(All accounts in child sub-MCC's of the excluded sub-MCC's would therefore also be ignored as well)
Perhaps if I can make it ignore ALL sub-MCC's that would work as I could then specify those sub-MCC's I do want specifically in my inclusion list or create copies of this script at the appropriate levels.

If this is not possible, can this then be a feature request? An option to exclude child accounts please?

Please help.

Justin Taylor

unread,
Dec 4, 2014, 3:08:12 AM12/4/14
to adwords...@googlegroups.com
Try this:

var accountIterator = MccApp.accounts().withIds(['123-456-7890']).get();


AussieWeb Conversion

unread,
Dec 4, 2014, 8:02:13 AM12/4/14
to adwords...@googlegroups.com
@Justin: That fails to return any accounts at all since '123-456-7890' in this case is a "Client Manager" so is not deemed to be an "account"

Justin Taylor

unread,
Dec 4, 2014, 6:54:35 PM12/4/14
to adwords...@googlegroups.com
OK so put the account numbers you want into the array:

var accountIterator = MccApp.accounts().withIds(['000-000-0000','111-222-3333']).get();

As long as the account (the MCC account) running the script has permission to access them you should be fine.

AussieWeb Conversion

unread,
Dec 4, 2014, 8:34:47 PM12/4/14
to adwords...@googlegroups.com
@Justin: We are a Premier Partner managing over 400 accounts and we gain new accounts every day.  I need this programmatically, not manually.

Justin Taylor

unread,
Dec 4, 2014, 9:14:30 PM12/4/14
to adwords...@googlegroups.com
Hmmmm.

It seems this is a good reason for a feature request. We need something like getChildAccounts() and getParentAccount() functions on the MccApp. They would need to function as only child and parent selectors, not ancestor selectors and thus only one level removed from the active account that is executing the script.

Does that sound about right?

AussieWeb Conversion

unread,
Dec 4, 2014, 10:42:28 PM12/4/14
to adwords...@googlegroups.com
Yes, something like getChildAccounts() and getParentAccount() functions on the MccApp could indeed prove useful.

In the meantime, I've finally come up with a work around that does what I want.

  //Determine the accounts that need to be excluded based on sub-MCC id
 
var excludedMCCIter = MccApp.accounts()
   
.withCondition("ManagerCustomerId IN ['111-222-3333', '444-555-6666', '777-888-9999']")
   
.get();

 
var excludeList = [];
 
while(excludedMCCIter.hasNext()) {
   
var account = excludedMCCIter.next();
    excludeList
.push(account.getCustomerId());
 
}

  //Format the results as string for use in .withCondition
 
var strExcluded = excludeList.join(",").replace(/-/g, "");

  //Grab all the accounts needed for processing from the main MCC and exclude those accounts specified above
 
var accountIter = MccApp.accounts()
   
.withCondition("ManagerCustomerId IN ['123-456-7890']")  //NB All sub-MCC's are included due heirarchy
   
.withCondition("CustomerId NOT_IN ["+strExcluded+"]") // ignore specific sub-MCC's as per above
   
.withLimit(50)
   
.get();

If anyone else needs this, Enjoy!

Anash Oommen

unread,
Dec 6, 2014, 7:49:01 AM12/6/14
to adwords...@googlegroups.com
Folks,

Thanks for reporting this. I'll file a feature request to see if we can provide a better solution.

Cheers,
Anash P. Oommen,
AdWords Scripts Team.

AussieWeb Conversion

unread,
Dec 7, 2014, 8:16:00 PM12/7/14
to adwords...@googlegroups.com
Thanks Anash.

Regards
Nigel

Alex Groenendijk

unread,
Dec 1, 2016, 11:36:20 AM12/1/16
to AdWords Scripts Forum
Hi folks, 

does anyone knows how I could exclude sub-MCC's in the latest MCC-link checker script (2.1)? If I use 'ACCOUNT_CONDITIONS' I only be able to include ID's (IN), not exclude (NOT-IN). If I use NOT IN, i'll get the following error: "Exception: One of the conditions in the query is invalid. (line 193)".

  // A list of ManagedAccountSelector conditions to restrict the population
  // of child accounts that will be processed. Leave blank or comment out
  // to include all child accounts.
  ACCOUNT_CONDITIONS: ["ManagerCustomerId NOT-IN ['012-345-6789']"],

Please help!

Op zaterdag 6 december 2014 13:49:01 UTC+1 schreef Anash Oommen:

Tyler Sidell (AdWords Scripts Team)

unread,
Dec 1, 2016, 12:59:01 PM12/1/16
to AdWords Scripts Forum
Hi Alex,

The correct syntax would be NOT_IN.  So just change NOT-IN to NOT_IN and you should be fine.  In the future, please open a new thread for better tracking purposes.

Thanks,
Tyler Sidell 
AdWords Scripts Team

AussieWeb Conversion

unread,
Dec 1, 2016, 8:05:00 PM12/1/16
to AdWords Scripts Forum
Hi Tyler

The NOT_IN syntax still doesn't work as expected.

function main() {
 
 
var accounts = MccApp.accounts()

 
.withCondition("ManagerCustomerId IN ['123-456-7890']")

 
.get();
 
var subAccounts = MccApp.accounts()
 
.withCondition("ManagerCustomerId IN ['987-654-3210']")
 
.get();
 
var noSubAccounts = MccApp.accounts()

 
.withCondition("ManagerCustomerId IN ['123-456-7890']")

 
.withCondition("ManagerCustomerId NOT_IN ['987-654-3210']")
 
.get();
   
   
Logger.log(accounts.totalNumEntities());
   
Logger.log(subAccounts.totalNumEntities());
   
Logger.log(noSubAccounts.totalNumEntities());
 
}

Time

Log
10:59:41.843
   391.0
10:59:41.952
   218.0
10:59:42.017
   391.0

If it was working, this last number would be 173.

Regards
Nigel

Tyler Sidell (AdWords Scripts Team)

unread,
Dec 2, 2016, 10:38:28 AM12/2/16
to AdWords Scripts Forum
Hi Nigel,

Thanks for this input.  I will bring the information back to the rest of the team.  If there is any updates, we'll update this thread.

Regards,
Tyler Sidell
AdWords Scripts Team

Keith Aldrich

unread,
Sep 6, 2017, 4:47:21 PM9/6/17
to AdWords Scripts Forum
Any updates on this? NOT_IN still doesn't seem to be working.

Anthony Madrigal

unread,
Sep 7, 2017, 9:17:20 AM9/7/17
to AdWords Scripts Forum
Hi Keith,

Unfortunately, there are still no updates on this issue.

Regards,
Anthony
AdWords Scripts Team

Paweł Kumor

unread,
Oct 12, 2017, 4:54:36 AM10/12/17
to AdWords Scripts Forum
Any estimation when it would start to work?

For me 

var accIt = MccApp.accounts().withCondition("ManagerCustomerId NOT_IN ['123-456-7890']").get();
Logger.log(accIter.totalNumEntities());

is causing:

Failed to read from AdWords. Please wait a bit and try again. (line 8)

Regards,
Paweł

Anthony Madrigal

unread,
Oct 12, 2017, 9:38:44 AM10/12/17
to AdWords Scripts Forum
Hi Pawel,

Our team is still working on getting a fix for this. Unfortunately, I cannot give any timelines.

I will update this thread as soon as this issue is resolved.

Regards,
Anthony
AdWords Scripts Team

Reply all
Reply to author
Forward
0 new messages