How to split Comma separated values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 12:44 AM
Hi All,
I am returning multiple location values under each country like below which has comma
Country A - av, mexico
Country A - abo,vig,abanaro
I need to get these locations when a specific country is selected and display only those locations.
As the locations include comma(,) how do I split and display
I am able to get the values like av, mexico,abo,vig,abanaro in the logs
but how do I set it in the locations field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 01:09 AM
Hi,
if it is a string, you can try
var countryA=av, mexico;
var name=countryA.split(',');
for(var i=0;i<name.length;i++)
{
var value=name[i];
}
if it is an array,
var countryA=[av,mexico];
for(var j=0;j<countryA.length;j++)
{
var value=countryA[j];
}
If the answer doesn't suffice , Could you please elaborate your requirement to set location?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 01:13 AM
HI,
Check this website. Maybe you will find some interesting information.
Please mark reply as Helpful/Correct, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 01:25 AM
hi
i checked in background script
var countryA="abo,vig,abanaro";
var name=countryA.split(',');
for(var i=0;i<name.length;i++)
{
gs.print(name[i]);
}
Thanks,
Rahul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 01:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 01:32 AM
yes it's working
Thanks,
Rahul Kumar