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
Hi @pavan patil ,
I would suggest If you’re passing the JSON to APIs, do not replace double quotes!. JSON.stringify already escapes inner quotes for you.
var body = {
description: g_form.getValue('description')
};
var jsonString = JSON.stringify(body);
// Now send jsonString in your API call
This will properly encode a description like:
He said "hello" → "description": "He said \"hello\""
Once receivers receive and decode will give the original description value.
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi Bhimashankar,
thanks for the response. Please find my below code. Anything I need to modify here.
var description = grIncident.getValue("description") || "";
if (description != "") {
description = JSON.stringify(description).replace(/“/g, ‘’);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @pavan patil ,
Replace line -> description = JSON.stringify(description).replace(/“/g, ‘’);
with
description = JSON.stringify(description)
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago