TypeError: cannot find function split

Hi,

the following line in my code works fine most of the time.

criteria = globals.svy_sea_criteria*.criteria.split('||')*
*```*
*sometimes the user gets an error on this line of code :* 
*```*
*org.mozilla.javascript.EcmaError: TypeError: cannot find function split.(<methodname and linenumber>)*
*```*
*What could cause this error ?*
*Regards,*

HI Hans,

Usually this means that the value you try to use the split() function on is null or not of type String.
So globals.svy_sea_criteria.criteria is most likely null (or svy_sea_criteria is null).
Hope this helps.

criteria isnt a string?

well,

this line of code evaluates the search criteria entered in a date field/column.

I tried to enter all kinds of data in that field ( date, text, number ) but I can not reproduce the “split” error.

Regards,

I tried to create a new variable as a number.

var aa
var bb
aa = 123
bb = aa.split('||');

This results in exactly the error the user gets.

I’ll investigate further. Thanks for the hint !!

Regards,

And svy_sea_criteria actually holds anything? I.e. is the value in ‘i’ still in the scope of the array ?

Hi Robert,

If I do the test with a null value the error is slightly different ( the Null also appears in the error message)

Thanks,