split a string with multiple values

jean-pauldehaas
Tera Guru

Hi,

 

i need to add a field map to map organizations from an external system.

the information that is coming in from the external system is like this " organization/EU/organizationname" i need to map the organizationname part to an existing field in SN.

 

i know i need to use the split in the source script but i need help on how to do this ?

1 ACCEPTED SOLUTION

You can use as below then

var str = "organization/EU/organizationName";
var organizationName;
var arr = str.split("/");
if(!(arr[2] == "" || arr[2] == undefined || arr[2] == null)){
organizationName = arr[2];
}
else
{
organizationName = arr[1];
}
gs.info("Organization Name: " + organizationName);

View solution in original post

10 REPLIES 10

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello @jean-pauldehaas ,

                                           You can use below script to split value from string 

var str = "organization/EU/organizationname";
var arr = str.split("/");
var organizationName = arr[2];
gs.info("Organization Name: " + organizationName);

Kindly mark correct and helpful if applicable

Hi Chetan,

 

Thanks!

i do have like 5 organizations i need to map , should i just use this script multiple times then ?

Hi @jean-pauldehaas ,

                                       Just confirm if this situation is correct , 5 organization in 1 string only (like organization/EU/organizationname1/2/3/4/5"; ) and you have 5 fields on form to map those right ?

hi,

 

its more like:

 

organization/EU/organizationname1

organization/EU/organizationname2

organization/EU/organizationname3

 

i need to write the script in a manner that if something in the structure changes it still works