How to parse double quotes in Jain.stringify

pavan patil
Tera Contributor

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, ' ');

 

20 REPLIES 20

@pavan patil ,

 

Make sure that replace is not used for any other field in your script.

 

Try logging the info that you are sending to REST, and check if the encoded is correctly happening. 

Log the data that you are sending and take that data validate the JSON, share any error that your are geting for other source.

 

The data should encode something like 

He said "hello" → "description": "He said \"hello\"".

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

 

Ankur Bawiskar
Tera Patron
Tera Patron

@pavan patil 

you can escape the double quotes.

how are you sending data to other instance?

Is it via REST Message?

Share that script and screenshots.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

Yes, its via REST Message.

@pavan patil 

share that complete script here

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@pavan patil 

are you using variable substitution to set the description and pass via REST Message?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader