- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 12:51 PM
Hi,
I'm trying to replace spaces in my string with a comma within a Run Script in my workflow, but I keep getting 'undefined'. This is what I've tried:
var copyNona3 = copyNona.replace(/,\s*$/, "");
var copyNona3 = copyNona.replace(/\s/g, ',');
var copyNona3 = copyNona.replace(/\s/g, ',');
But none of that worked. I also joined a split().join() but that didn't work either.
Can you use replace in a Run Script of a workflow?
Thanks.
Phuong
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 01:02 PM
If you are getting undefined while calling replace, then copyNona might not be a string. Convert to string and then check it.
If you are getting undefined while printing copyNona3, thjen try this code
var copyNona2 = "Testing";
var copyNona3 = copyNona2.replace(/\s/g, ',');
Mark the comment as a correct answer and helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 01:05 PM
got it - need to put in string first...thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 01:02 PM
If you are getting undefined while calling replace, then copyNona might not be a string. Convert to string and then check it.
If you are getting undefined while printing copyNona3, thjen try this code
var copyNona2 = "Testing";
var copyNona3 = copyNona2.replace(/\s/g, ',');
Mark the comment as a correct answer and helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 01:04 PM
Aaaah yes that was it. Thank you!