- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 06:44 AM
Hello,
we have a functionality where we create incidents from portal (functionality is similar to that of record producers but it is a customized one and it is to be noted that we copy data from certain fields and add the whole data in the description of the incident. some of these fields are html and when we check the incident description, we see some unwanted data like "+" etc instead of some symbols.
I used GlideSPScriptable().stripHTML(current.description.getValue()) in a business rule, with this the symbols appear as symbols and unwanted data is removed but the structure of description is lost. As I mentioned, description field is a combination of some other fields and this data is now unstructured without proper new lines.
How do I change it so that format is not lost?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 07:21 PM
Hi,
My apologies, I didn't see you mention that you had tried that in your original post. If you've tried anything else, feel free to let us know so that we don't waste your time with methods you've already attempted.
With that said, stripping out the HTML, which you're relying on for spacing, will break the text when you replace it back as you have in fact...removed the HTML. You may want to attempt another method, such as a combination of what I mentioned previously, then a second scrub of additional characters you are seeing (such as the removal of + and '). This will take some trial and error to get right, but may be the best option, for now.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 06:54 AM
Hello,
If the HTML is including the line breaks and then you're stripping the HTML...you'll lose the formatting.
You may want to consider using something like this: https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc... - which renders everything properly, but you may still see the HTML. You can then review how best to remove that as you need.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 07:06 AM
Hi @Allen Andreas ,
Thanks for replying.
I have tried using this earlier but this is only working for some symbols (This method replaces these escape characters: < >: & "e;.) I still see weird text for some characters like + and single quotes .
Have tried with both these but no luck
GlideStringUtil.unEscapeHTML(//myfield);
JSUtil.unescapeText(//myfield).
Could you please guide me here?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 07:21 PM
Hi,
My apologies, I didn't see you mention that you had tried that in your original post. If you've tried anything else, feel free to let us know so that we don't waste your time with methods you've already attempted.
With that said, stripping out the HTML, which you're relying on for spacing, will break the text when you replace it back as you have in fact...removed the HTML. You may want to attempt another method, such as a combination of what I mentioned previously, then a second scrub of additional characters you are seeing (such as the removal of + and '). This will take some trial and error to get right, but may be the best option, for now.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!