We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Is substring() method available in the String object in non global scope?

SwarnadeepNandy
Mega Sage

I am using below code in some non global   application scope

current.floor   =   parseInt(current.room.substring(0,1)); // where 'room' is string type and 'floor' is integer type.

but it is not working, i am getting error

find_real_file.png

but when i am using

current.floor = parseInt(current.room.toString().substring(0,1));

it is working perfectly fine.

Why do i need to use toString() for a string type variable?

5 REPLIES 5

Yes thats the thing. I thing for the security issues they have restricted access.