How to parse double quotes in Jain.stringify

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi, I’m facing an issue with a record producer that is configured as a catalog item on the Employee Center portal. The form has a Description field, which is a free-text field.
The problem occurs when we enter text that contains double quotes. For example, if the user enters something like "test" in the Description field and submits the form, the request fails, and the incident is not created in the target instance.
This setup is part of our e-bonding integration between two ServiceNow instances. Normally, when a request is submitted through the record producer in the source instance, it creates an incident in the target instance. However, the integration only fails when the Description field contains double quotes.
When the Description does not include double quotes, the incident is created successfully in the other instance.
Could you please help me with this issue?
we are using the code in our script include :
JSON.stringify.replace(/“/g, ' ');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
you can use setStringParameterNoEscape() method and it will allow sending double quotes and the integration will work fine
RESTMessageV2 - setStringParameterNoEscape(String name, String value)
another way if you are using variable substitution below
Outbound REST message fails due to incorrect escaping in variable substitutions
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
4 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
So if it didn't work then did you try this?
Outbound REST message fails due to incorrect escaping in variable substitutions
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
4 weeks ago
Hi @Ankur Bawiskar ,
Please find my below, if we enter the text called "test" on the description field it is not allowing to create a incident on the other instance. Could you pls let me know if any changes to be done, in order to accept the double quotes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 3 weeks ago
Hey @pavan patil ,
Try the below code.
createIncident: function(grIncident) {
var result;
// Formatting journal fields
var workNotes = JSON.stringify(grIncident.work_notes.getJournalEntry(-1) || "");
var comments = JSON.stringify(grIncident.comments.getJournalEntry(-1) || "");
var testComments = workNotes + comments;
// Formatting description
var description = grIncident.getValue("description") || "";
description = JSON.stringify(description)
var shortDescription=grIncident.getValue("short_description")
shortDescription=JSON.stringify(shortDescription);
if (this.DEBUG) {
gs.info("SNIntegrationUtils - createIncident - WORK NOTES:\n" + workNotes);
gs.info("SNIntegrationUtils - createIncident - COMMENTS:\n" + comments);
gs.info("SNIntegrationUtils - createIncident - testComments:\n" + testComments);
}
try {
var r = new sn_ws.RESTMessageV2('Demo ServiceNow', 'ManageIncident');
// Static values
r.setStringParameterNoEscape('task', "-1");
r.setStringParameterNoEscape('correlation_display', "Test");
r.setStringParameterNoEscape('cmdb_ci', "Test 1");
r.setStringParameterNoEscape('category', "Test 2");
r.setStringParameterNoEscape('subcategory', "Test 3");
r.setStringParameterNoEscape('channel', "Test 4");
// Dynamic values (no double quote replacement needed, just raw strings)
r.setStringParameterNoEscape('notes', testComments);
r.setStringParameterNoEscape('description', description);
r.setStringParameterNoEscape('short_description', shortDescription);
r.setStringParameterNoEscape('correlation_id', grIncident.getUniqueValue());
// Processing the request
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (this.DEBUG){
gs.info("SNIntegrationUtils - createIncident - requestBody: \n\n" + r.getRequestBody());
gs.info("SNIntegrationUtils - createIncident - httpStatus: " + httpStatus);
gs.info("SNIntegrationUtils - createIncident - responseBody: " + responseBody);
}
result = {
"httpStatus": httpStatus,
"responseBody":responseBody
};
}
catch(ex) {
var message = ex.message;
if(this.DEBUG){gs.info("SNIntegrationUtils - createIncident - message: " + message);}
result = {
"httpStatus": httpStatus,
"responseBody":null
};
}
return result;
},
Check once, the logged values after trigger. Let me know the results.
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!