Escape characters within JSON object not working, even when converted to a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2020 03:13 PM
Hello,
Using Flow Designer, I'm trying to update the work notes field of an Alert with the response body from a REST step. This is fine, but the resulting work note ignores escape characters, specifically "\n".
Is there a reason this could be happening, and is there a workaround to get escape characters to work?
I have tried manually converting the JSON object to a string using .stringify(), but the same issue remains. I've tried escaping the escape with "\\n". The same issue is occurring when updating an Alert manually through a glide record object.
Thank you.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 08:39 AM
Hi Ashutosh,
Thanks for the response.
<br/> and other escape characters are not working as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2023 08:37 AM
If you construct JSON in a script then ServiceNow automatically escapes special characters
for example
If you want to create an incident JSON below code should escape any characters that would break JSON in short description for example if short description is technology issue" ..}
output would look like this
*** Script: [DEBUG] technology issue" ..}
*** Script: [DEBUG] object
*** Script: [DEBUG] {"number":"INC0010004","shortDesc":"technology issue\" ..}"}
[0:00:00.005] Total Time