How to script out STARTSWITH in script include?

mdjoseph12
Giga Contributor

Does any one know if the way that I've scripted the STARTSWITH function within this if statement is correct? 

 

if(teamName.startsWith('')||teamName.startsWith('')||teamName.startsWith('')){

 

 

1 ACCEPTED SOLUTION

Rogers Cadenhe1
Giga Guru

It looks correct as long as teamName is a string.

When I call String functions in SN I often make sure they are strings first with a line like this:

var teamName = "" + current.getValue('team_name');

Or this:

var teamName = current.getValue('team_name').toString();

View solution in original post

2 REPLIES 2

Rogers Cadenhe1
Giga Guru

It looks correct as long as teamName is a string.

When I call String functions in SN I often make sure they are strings first with a line like this:

var teamName = "" + current.getValue('team_name');

Or this:

var teamName = current.getValue('team_name').toString();

Prateek kumar
Mega Sage

Why not use the encoded query instead

nameSTARTSWITH

https://docs.servicenow.com/bundle/london-platform-user-interface/page/use/using-lists/concept/c_EncodedQueryStrings.html


Please mark my response as correct and helpful if it helped solved your question.
-Thanks