Remove HTML coding from incoming Incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 12:30 PM
Hi All,
I was wondering if someone could help me understand how to code this change.
Id like to remove all the html coding from this paragraph but not sure how to format the business rule.
Below is an example of the text that appears in our description field (This field is not HTML)
[code]<h3>RESOLVED Problem <i>test</i></h3><br><small>Problem detected at: 19:02 (UTC) 13.12.2022 - 19:47 (UTC) 13.12.2022 (was open for 45 min)</small><hr><b>1 impacted service</b><hr><br><div><span>Web request service</span><br><b><span style="color:#7dc540; font-size:120%">Requests</span></b><br><p style="margin-left:1em"><b><span style="font-size:110%">Failure rate increase</span></b><br>requests/min impacted<br>your fixed threshold of 50 % was exceeded to 100 %<br>Service method: </p></div><hr><p><a target="_blank" href="link">Open in Browser</a></p>[/code]was[code]<h3>OPEN environment <i>Instance</i></h3><br><small>Problem detected at: 19:02 (UTC) 13.12.2022</small><hr><b>1 impacted service</b><hr><br><div><span>Web request service</span><br><b><span style="color:#dc172a; font-size:120%">Requests</span></b><br><p style="margin-left:1em"><b><span style="font-size:110%">increase</span></b><br>10.2 requests/min impacted<br>your fixed threshold of 50 % was exceeded to 100 %<br>Service method: All dynamic requests</p></div><hr><p><a target="_blank" href="link">Open in Browser</a></p>[/code]
This is in my current business rule that i pulled from the community, that does remove some of the HTML but not all of it such as [/code],<hr>,<br>
var desc=current.description;
desc= desc.replace(/<\/?[^>]+(>|$)/g,"");
Can someone recommend how to replace these HTML tags on Insert ? Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 11:13 AM
I was able to get this working in a business rule to where it is a legible description in our notifications, thank you for assisting me, much appreciated.
(function executeRule(current, previous /*null when async*/) {
var htmlString = current.description.getHTMLValue(); ////
var stringHtml = GlideSPScriptable().stripHTML(htmlString);
current.description = stringHtml;
})(current, previous);