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

Mihir Mohanta
Kilo Sage

1.Description is already a translated html type of field.If you select


find_real_file.png



Then it will acts as <b> tag of html.


Like wise you can select other symbols in this field and these are automatically translated to html tags and appear in the catalog form.




Thanks,


Mihir


Jim Coyne
Kilo Patron

Can you share the actual HTML source code that appears when you click on the "Source code" button in the editor:


find_real_file.png



find_real_file.png



That should give us an idea of what is going on.


And another question - I'm assuming you are encoding the data sent over the web service, so are you decoding it first before inserting/updating the Catalog Item record?


Mussie
ServiceNow Employee

Hi Jim,


This is what I am getting:


find_real_file.png



Mussie