- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 06:18 AM
ISSUE DESCRIPTION
I have an outbound REST message that sends incident information to the desired endpoint. The challenge I am having is the following special characters need to be escaped in the Short Description, Description, Comments, and Work Notes.
„ € ‚ … ˆ ‹ ' ' " " • – — ˜ ™ ›
WHAT'S IN PLACE NOW
I'm working with a script includes that populates the REST message and I'm unclear how the replace components are intended to work.
Here are the statements in question:
this.workNotes = this.workNotes.replace(/(\r\n|\n|\r)/gm, " "); - What is this replace doing?
this.restMessage.setStringParameter('briefDescription', this.current.short_description.replace(/"/g, "'"));
this.restMessage.setStringParameter('description', this.current.description.replace(/"/g, "'"));
For the last 2 statements, I understand the desired outcome is to replace double quotes with single quotes, but it is not working as desired.
WHAT I NEED
This is outside my area of expertise.
The content of the description is often a copy and paste from an email. How do I escape these special characters in the script includes, so that they appear as they are entered in the incident record
„ € ‚ … ˆ ‹ ' ' " " • – — ˜ ™ ›
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 10:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 10:16 AM
have you tried setStringParameterNoEscape
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 02:31 PM
Thanks, I have changed the script includes to use setStringParameterNoEscape.
The special characters appear as they are entered in the description.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 10:27 AM
The replace seems to replace all that match the regular expression /(\r\n|\n|\r)/gm enters and new line symbols. It replaces them with spaces
Have you tried adding the characters to that?
Like so:
this.workNotes.replace(/(\r\n|\n|\r|„|€|‚|…|ˆ|‹|'|'|"|"|•|–|—| |™|›)/g, " ");
Example when I use it in background script like this:
var workNotes = "this 'is' an €xample";
workNotes = workNotes.replace(/(\r\n|\n|\r|„|€|‚|…|ˆ|‹|'|'|"|"|•|–|—| |™|›)/g, " ");
gs.print(workNotes)
It returns:
*** Script: this is an xample
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 12:34 AM
We can use JSON Stringify function
let escapedJson = JSON.stringify(data);