Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

incident integration

Jack62
Giga Guru

Afternoon all

 

I have an integration with another ServiceNow instance and creating and updating does not work if I have special characters in the short description and description. The line I am adding is (!@#$%^&*()\|[]{}<>|"&'%)
µë-Ö׬¶X§{. There is nothing on the business rule or Rest message that should stop this from going to the other side. What have I done wrong, or probably what have I not added in?

 

Thanks

 

Jack

1 ACCEPTED SOLUTION

Weird
Mega Sage

Are you currently using setStringParamer? Have you tried using setStringParameterNoEscape for fields that can contain special characters?

View solution in original post

7 REPLIES 7

Weird
Mega Sage

Are you currently using setStringParamer? Have you tried using setStringParameterNoEscape for fields that can contain special characters?

Could you confirm where I would set that? I have the below set in my business rule but it i still not working;

 

var s = new sn_ws.RESTMessageV2('incident integration', 'Create new ticket');
            s.setRequestBody(JSON.stringify(test));
            s.setStringParameterNoEscape('ticketno',ticketno);
                var response = s.execute();
           var responseBody = response.getBody();
            var httpStatus = response.getStatusCode();
            gs.log('Ensono responsebody: ' + responseBody );
        gs.log('Ensono status' + httpStatus);

Oh, you're using setRequestBody here. I'll assume your test variable is an object that contains the short_description and description?

I just noticed you had " and ' in your value and it might break something whne using setRequestBody.
So when setting the description or short description, you'd want to escape that.
For example:
var test = {};
test.description = incident.description.replaceAll('"', '\"');

It's a bit hard to see, but I'm using ' and " here. I surrounded " with ' and then told the script to replace " with \".
Can you give that a try? So just add .replaceAll('"', '\"'); to where ever you're setting the description/short description at.

AshishKM
Kilo Patron
Kilo Patron

Hi @Jack62 , 

Did u check any regEx applied on target instance for short description/description field.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution