Displaying HTML Field as Normal Text

Lokesh5
Tera Contributor

I am currently working on the sn_grc_issue table, which includes an HTML-type field called Description. When I try to print the value of this field, the output includes HTML tags. However, I would like to render the HTML content as normal text instead. Specifically, if the HTML contains table tags, the output should be displayed in a tabular format.

 

Could anyone please guide me on how to achieve this?

 

SCRIPT:

Lokesh5_0-1736340214204.png

 



Output:
Lokesh5_0-1736340037498.png

 




2 REPLIES 2

Shruti
Mega Sage
Mega Sage
    var strng1 = issues.description.toString();
    var strng2 = strng1.replaceAll('<p>', '');
    var strng3 = strng2.replaceAll('</p>', '');
    var strng4 = GlideStringUtil.unEscapeHTML(strng3);
    var strng5 = strng4.replaceAll('<br />', '');
    gs.info(strng5.toString());

Ankur Bawiskar
Tera Patron
Tera Patron

@Lokesh5 

not possible directly to handle it.

you can remove html tags and get the plain text but you won't get the data in tabular format

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