Field name Labels is invalid. Please check your spelling and casing. (line 65)

365 views
Skip to first unread message

Clive

unread,
Nov 14, 2014, 1:22:51 PM11/14/14
to adwords...@googlegroups.com
Hi guys
I know this has been asked before and resolved at the time as a bug in adwords script code itself, but I am encountering the above error again in the following code....(line 65 is the line beginning "while...")


var labelSelector = AdWordsApp.labels()
     .withCondition('LabelNames STARTS_WITH_IGNORE_CASE 20141112')
     .orderBy("LabelNames DESC");
  
var labelIterator = labelSelector.get();

while (labelIterator.hasNext()) {
   var label = labelIterator.next();
   Logger.log(Utilities.formatString('Currently working on label', label)); 

Please can you help?

Thanks
Clive

Alexander Wang

unread,
Nov 14, 2014, 3:25:36 PM11/14/14
to adwords...@googlegroups.com
Hi Clive,

The issue is that "LabelNames" is not a valid field for LabelSelectors. Instead you just want to use "Name". Something like:
function main() {
 
// Change prefix to what you want.
 
var labelPrefix = 'b'
 
var labelSelector = AdWordsApp.labels()
     
.withCondition('Name STARTS_WITH_IGNORE_CASE ' + labelPrefix)
     
.orderBy("Name DESC");



 
var labelIterator = labelSelector.get();


 
while (labelIterator.hasNext()) {
   
var label = labelIterator.next();

   
Logger.log(Utilities.formatString('Currently working on label %s', label.getName()));
 
}
}

LabelNames is a valid condition for CampaignSelectors, AdGroupSelectors, AdSelectors, and KeywordSelectors. For more info on Labels, I recommend looking at some of our developer site documentation:

Let us know if you have any other questions/issues.

Cheers,
Alex

Clive

unread,
Nov 15, 2014, 4:00:19 PM11/15/14
to adwords...@googlegroups.com
Alex
Thanks very much. I will give this a go.
Regards
Clive
Reply all
Reply to author
Forward
0 new messages