AdGroup selector: filtering for an ID from Google Spreadsheet

11 views
Skip to first unread message

Daniel Molnar

unread,
Sep 13, 2021, 3:23:21 AM9/13/21
to Google Ads Scripts Forum
I am trying to build a selector for adgroup names, where the filtering criteria is a number (an ID) and I want to retrieve all the AdGroups where this id is existent in the AdGroup name.

I get the ids from a Google Spreadsheet and tried to convert to a string, but it doesn't give any result. When I replace the productId just with a normal value it gives results.

var productId = newSheet.getRange(i,2).getValue().toFixed(0);
var adgroupIterator = AdsApp.adGroups().withCondition("Name CONTAINS '"+ productId +"'").get();

Could you suggest a solution for this?

Thanks,
Daniel
   

Google Ads Scripts Forum Advisor

unread,
Sep 13, 2021, 5:59:31 AM9/13/21
to adwords...@googlegroups.com
Hi Daniel,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team.

Format differs for when you use string variables in script conditions. Kindly try this withCondition syntax instead: 'Name CONTAINS '"'+ productId +'"' and let me know how it goes.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2NTZTv:ref
Reply all
Reply to author
Forward
0 new messages