Skip to main content

We have integrated our Freshservice environment to a partner’s Service Now environment, which is working very well - with one exception.  The formatting of the Service Now text is getting removed during the integration. 

Here’s an example message that’s coming from Service Now.  The \r\n line breaks are showing this across multiple lines in Service Now.

"Your issue (INC-1XXXX) has been deemed solved.  Please review the attached notes for more information: Good morning!\r\n\r\n I have added the XXXXX. This section of the XXXX.\r\n\r\nRegards\r\nXXXX "

The body of the POST Command includes the following line: 
  "Description": "{{ticket.description | sanitize_html}}"

I believe santize_html is removing the \r\n breaks from the description as it’s handled in the POST processing.  Is there a way to allow for these to be included, or to replace the \r\n with a <BR> character before it’s cleaned up by the sanitize_html command?

Have also seen a reference to try {{ticket.description | url_encode }} as an alternative.

Looking for some community guidance, as it seems like it would be a common, relatively straightforward solution.

Thanks in advance!  
Kevin



 

@KVertrees You’ve posted in a FreshDesk group - you’ll have more joy in the FreshService group.


I have moved the topic to Freshservice !!!! 


Hello! Good day. Thanks for reaching out to us on the community.

Regarding your query, the issue you’re encountering is caused by the sanitize_html filter, which strips out HTML tags and formatting, including line breaks (\r\n). To resolve this, instead of using sanitize_html, you can replace the \r\n line breaks with <br> tags before the sanitization process. Update the body of your POST command as follows to implement this:

"Description": "{{ticket.description | replace: '\r\n', '<br>' | sanitize_html}}"

This will replace all \r\n breaks with <br> tags and then sanitize the content to retain safe HTML formatting when posting to ServiceNow.

Alternatively, if you’d like to URL encode the description instead, you can use url_encode to ensure proper formatting:

"Description": "{{ticket.description | url_encode}}"

Choose the approach best suited to how ServiceNow processes the incoming text. If the <br> tag approach doesn't work due to ServiceNow restrictions, the url_encode method provides a fallback to handle formatting.

I hope this helps.


Reply