replace double quotes with "\ when sending REST message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:00 AM
i need to replace double quotes with "\ when sending REST message. but when used below replace method, the final output which user receives in email is coming as "Testing double quotes"
first in WF : i am setting sub value and using the below
"Testing double quotes"
please help me, as this issue is occuring when user is entering the subject value in the record with double quotes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:02 AM
what's your business requirement here?
are you facing an issue while sending double quotes in REST Message body?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:37 AM
requirement is. servicenow is sending double quote but the external system(esign tool) is not able to process it stating incorrect JSON structure. so they are saying to replace double quotes with "\, so their tool can accept this JSON value and will send the double quotes as it is to user
Basically they are using this value as subject line to send email notification to end user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:51 AM
your line of code worked for me.
what's not working in your case?
var str = 'Hello " Adam';
var sub1 = str.replace(/"/g, '\\"');
gs.info(sub1);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 02:12 AM
Right same for me. what i discovered is, the payload is hitting to external system correctly however while it sends an email to user, it is showing the subject line as : "Testing double quotes"
So i think external system is not able to process it properly. so at the moment it doesn't look an issue at servicenow.