Unable to split parm in email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
56m ago
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 ~ ...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11m ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
36m ago
