Convert comma separated string to array in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 02:37 AM
Hi there,
I have a comma separated string(ex: {Shoe,Tie,Blazer}) in my client script. This string needs to be passed to a script include and there i need to split in to an array.
I tried using string.split(',') method, but no luck.
Can somebody help if there is a method to convert the string into array in script include, please?
Thanks,
Venu
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 02:46 AM
split should work in script include.
var spl = name.split(',');
again you have to use like spl[0],spl[1] like this way
Can you please pose your total script, what you need to acheive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 02:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2017 10:24 AM
The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Referencing a Glide List from a Script
Visit http://docs.servicenow.com for the latest product documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 03:11 AM
Hi,
This should work, please change your string as shown
var str = "Shoe,Tie,Blazer";
var arr = str.split(",");
//alert(arr[0]);
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response