How to add html tags to description field of a service catalog item?

Mussie
ServiceNow Employee

Hi All,

I have got a requirement where I need to be put HTML tags to the description field. This is because the catalog items are being pushed from a third party system using a web-services integration. I know you can edit this using the features available in the text such as bold, italics etc but the integration is supposed to be fully automated without any manual intervention.

Hence, when I tried to use HTML tags, it is translating them literally, any ideas?

find_real_file.png

find_real_file.png

Mussie

1 ACCEPTED SOLUTION

You could transform that field by using the "unescapeText" method in the JSUtil Script Include (JSUtil - ServiceNow Wiki).   It will restore the string back to "normal" HTML code for you.   The example in the Wiki article shows the exact same issue you are running into.



Your code would be as simple as something like (untested):


target.description = JSUtil.unescapeText(source.u_description);


View solution in original post

11 REPLIES 11

OK, so we need to see how the data is coming in to that field now from the web service.   Can you share the data?   Are you just taking the data as is and dropping it into the field or are you manipulating it somehow, etc...


Mussie
ServiceNow Employee

Hi Jim,


Thanks for your response. At the moment, the catalog items are pushed daily from a third-party application into ServiceNow via a Webservices Import set then onto sc_cat_items table. And the description data is just plain text at the moment and the requirement is to have html tags included. There is no data manipulation going on at the moment, we are pushing the data as is.


Mussie


Hi Mussie,



You have to request third party application owner while pushing data to servicenow convert it in HTML or before data push in target table convert the plain text in to HTML.



Regards,


Abhishek Verma


You could transform that field by using the "unescapeText" method in the JSUtil Script Include (JSUtil - ServiceNow Wiki).   It will restore the string back to "normal" HTML code for you.   The example in the Wiki article shows the exact same issue you are running into.



Your code would be as simple as something like (untested):


target.description = JSUtil.unescapeText(source.u_description);


Mussie
ServiceNow Employee

Thanks for your help Jim, I will test it and let you know...I will mark it as correct answer for now until I test it and know the results.