Convert HTML to string.

Kevin Smith2
Giga Expert

Hi,

How can we convert HTML to string ?

Is this possible ?

Thanks

Kevin

1 ACCEPTED SOLUTION

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi Kevin,

try using the solution posted by gjz, it should work:

https://community.servicenow.com/community?id=community_question&sys_id=64b0d219db76574054250b55ca96...

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

View solution in original post

6 REPLIES 6

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi Kevin,

try using the solution posted by gjz, it should work:

https://community.servicenow.com/community?id=community_question&sys_id=64b0d219db76574054250b55ca96...

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

Thanks Alberto, This worked.

Jaspal Singh
Mega Patron
Mega Patron

Hi Kevin,

 

As it is possible. You can use snippet as below.

var gr = new GlideRecord('task');
gr.get('sys_id');
var htmlDesc = gr.description.getDisplayValue();
var txtDesc = htmlDesc.replace(/<(?:.|\n)*?>/gm, '');
gs.print(txtDesc);

For additional references check the link suggested by Albert & additionally check link.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kevin,

you will have to remove the html tags

this script should work fine

var str = htmlValue.replace(/<\/?[^>]+(>|$)/g, "");

gs.info(str);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader