Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Unable to split parm in email script

dauger
Tera Contributor

Hello devs!

 

I am having trouble with parm2 in an email script I am writing.

 
var parm = event.parm2;
var splitParm = parm.split('~');

 

Using that code I had thought splitParm would be delimited by ~ but when I print splitParm the data is delimited by ;

 

Am I going about this the wrong way? How can I have parm2 use ~ as a delimiter?

 

Let me know if there's any other information needed.

6 REPLIES 6

Juhi Poddar
Kilo Patron

Hello @dauger 

 

Could you please share what value you have in parm2?

For split("~") to work, the actual string must contain the ~ character as the delimiter.

 

If your data in parm2 is separated by ; , then using split("~") will not change the string because the ~ character does not exist in it. That is why the data still appears to be ; separated.

 

In that case, you would need to use:

var splitParm = parm.split(';');

or ensure that the value being passed to parm2 contains ~ as the delimiter.

Hope this helps!


"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"


Thank You
Juhi Poddar

dauger
Tera Contributor

Hello @Juhi Poddar,

 

Then that is my problem! parm2 is delimited by ;

 

I thought split makes the data be delimited with whatever you pass into split.

 

That said, how can I ensure parm2 is delimited by ~ ...?

Hello @dauger 

 

You can try this:

var parm = event.parm2;

// convert ; delimiter to ~
var updatedParm = parm.split(';').join('~');

// now split using ~
var splitParm = updatedParm.split('~');

or

var parm = event.parm2;
parm = parm.replace(/;/g, '~');
var splitParm = parm.split('~');

Hope this helps!

 

Thank You
Juhi Poddar

Tanushree Maiti
Giga Sage

Hi @dauger 

 

Can you put  log/print   parm and splitParm and share the log.

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: