How to get raw text from HTML field?

tombialkowski
Giga Expert

Hi all,

We have a catalog item with a description (Example - "Description of Cat Item"), but this is an HTML field and the escription field of the actual catalog tasks are plain text. From within a workflow I am trying to retrieve the plain text version of the Catalog Item description field, and assign it to the description field in the Catalog Task that's created.

Here's what I've got so far:

        task.description = current.cat_item.description.getDisplayValue();

It works in the sense that it populates the Catalog Task description, but the HTML tags are included as well (Example - <p>Description of Cat Item</p>)

I know some old non-ServiceNow tricks where you can use a DIV tag to get to the textContent, but I'm not sure how to go about this in ServiceNow. Any suggestions?

1 ACCEPTED SOLUTION

tombialkowski
Giga Expert

Disregard - I went the route of using a regexp to trim out the tags.


View solution in original post

5 REPLIES 5

Hi Tom,


Thank you very much for the code. How can I replace images with space?


Dilini