Worknotes are displaying in HTML format

Sakshi Lambat
Tera Contributor

Hi All,

We have done the Sentinel to ServiceNow bidirectional Integration but while updating the worknotes in Incident from Sentinel it is coming in but in HTML format but I want it to be update as plain text. 

Please help me to resolve the issue.

 

Thanks and Regards,

Sakshi

3 REPLIES 3

Krushna R Birla
Kilo Sage

Hi @Sakshi Lambat 

 

You can refer below code for your reference, here we need to remove all tags from html body and then we can set the plain text to worknotes

 

var htmlFieldValue = '<p><span dir="ltr">App Rat Indicators :<strong>Usage Data</strong> - Data in place for 341 , T<strong>otal Cost of Ownership (TCO)</strong> - Data in place for 619 , <strong>Technical Deb</strong>t - Data in place for 121 , Integration Count - Data in place for 25, <strong>Incident Count </strong>- Data in place for 472 , <strong>Change Request Count</strong> - Data in place for 394</span></p><p> & nbsp; </p>';
var plainText = stripHTMLTags(htmlFieldValue); //stripHTMLTags function call which removes all tags
gs.info(plainText); //You can set the plainText value to worknotes in your code

function stripHTMLTags(htmlFieldValue) {
    // Remove CDATA tags
    var cleanedString = htmlFieldValue.replace(/<!\[CDATA\[|]]>/g, "");
    // Remove HTML tags
    cleanedString = cleanedString.replace(/<\/?[^>]+(>|$)/g, "");
    return cleanedString;
}

KrushnaRBirla_0-1728555559000.png

 

This will definitely helps you to resolved your issue. Let me know in case you need to understand anything, you can DM on LinkedIn.

 

If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

 

Best Regards,
Krushna Birla

Hi @Sakshi Lambat 

 

If this above solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

 

Best Regards,
Krushna Birla

The code would work but where would you put it to resolve the issue of the Sentinel integration updating the worknotes?

 

All I can think of is adding a BR to 'sys_journal_field' or related tables which does not sound like a good idea...