- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2019 06:54 AM
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('')){
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2019 06:59 AM
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();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2019 06:59 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2019 06:59 AM
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