Convert comma separated string to array in script include

vallamreddyvenu
Giga Contributor

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

4 REPLIES 4

BALAJI40
Mega Sage

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


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


Alikutty A
Tera Sage

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