AdWords
2.4K members online now
2.4K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

TypeError: Cannot call method "toLowerCase" of undefined

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

I'm using the standard Adwords script provided bij the developers team of Google = https://developers.google.com/adwords/scripts/docs/solutions/weather-based-campaign-management

 

But when we run the script, we receive the error message: TypeError: Cannot call method "toLowerCase" of undefined. (line 107)

 

The code on line 107  = if (campaignRulesData[i][5].toLowerCase() == 'yes') {

 

A solution provided in other communities was to change yes into no; we got the same error message.

 

Hope someone in here can give me some help,

 

Kind regards,

 

Jeremy

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author dutchlearning m
July 2016

Re: TypeError: Cannot call method "toLowerCase" of undefined

[ Edited ]
Top Contributor
# 2
Top Contributor

Hi @dutchlearning m, "undefined" in coding usually means that something is entirely missing, rather than being an unexpected value.  In this case, the line of code is checking the remote Docs spreadsheet for the contents of the cells in column F (which is column 5, counting from 0).  The error message is essentially saying that there's nothing in row i, column 5, so it's throwing an "undefined" error (you can't cast "nothing" to lower case!).  (The lower case method itself is irrelevant, that's just a typical programmers fix to allow for variations in capitalisation in an expected word).

 

Check the spreadsheet and make sure there's an entry in column F for every row and make sure you don't have any content in any cells below the last line of real data (possibly hidden below the fold, so scroll down).  The script retrieves all the data in the sheet, and "i" is the number of rows in that data.  So if there was even a single letter some rows below the actual data, the script would think there were too many rows and once i goes past the real data, it'll throw this error.

 

I'll bet my hat that the problem is in the spreadsheet.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author dutchlearning m
July 2016

Re: TypeError: Cannot call method "toLowerCase" of undefined

[ Edited ]
Top Contributor
# 2
Top Contributor

Hi @dutchlearning m, "undefined" in coding usually means that something is entirely missing, rather than being an unexpected value.  In this case, the line of code is checking the remote Docs spreadsheet for the contents of the cells in column F (which is column 5, counting from 0).  The error message is essentially saying that there's nothing in row i, column 5, so it's throwing an "undefined" error (you can't cast "nothing" to lower case!).  (The lower case method itself is irrelevant, that's just a typical programmers fix to allow for variations in capitalisation in an expected word).

 

Check the spreadsheet and make sure there's an entry in column F for every row and make sure you don't have any content in any cells below the last line of real data (possibly hidden below the fold, so scroll down).  The script retrieves all the data in the sheet, and "i" is the number of rows in that data.  So if there was even a single letter some rows below the actual data, the script would think there were too many rows and once i goes past the real data, it'll throw this error.

 

I'll bet my hat that the problem is in the spreadsheet.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

Re: TypeError: Cannot call method "toLowerCase" of undefined

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Jon,

Thank you so much!

Script is working :-)