- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 08:21 AM
HI Team,
In the HR Module, we are using the rich_description field. Any text entered into the rich_description field. It is also copied into the description field as per the out-of-the-box behavior.
However, while copying the data, it includes HTML tags.
Is this out-of-the-box behavior if we choose to use the rich_description field?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 10:12 AM
If you want to preserve only the plain text in description, you should strip the HTML tags when copying from rich_description.
Use BR....
function stripHTML(html) {
var tmp = new GlideElement();
tmp.setDisplayValue(html);
return tmp.getDisplayValue().replace(/<[^>]*>/g, '');
}
// In Business Rule:
current.description = stripHTML(current.rich_description);
or Flow (script step)
var plainText = current.rich_description.replace(/<[^>]*>/g, '');
current.description = plainText;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 08:26 AM
Hi @VasukiS ,
The inclusion of HTML tags when copying data from the rich_description field to the description field is indeed the out-of-the-box behavior in ServiceNow. This happens because the rich_description field uses a rich text editor, which stores content as HTML to preserve formatting (like bold, italics, lists, links, etc.).
If the requirement is to strip the HTML tags before copying the content to the description field, you can use the gs.stripHTML() function in a business rule or a script include to handle this.
If my response was helpful, please mark it as the correct answer and close the thread. This will help others who come across the same issue.
Thanks!
Gaurav Rathaur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 10:12 AM
If you want to preserve only the plain text in description, you should strip the HTML tags when copying from rich_description.
Use BR....
function stripHTML(html) {
var tmp = new GlideElement();
tmp.setDisplayValue(html);
return tmp.getDisplayValue().replace(/<[^>]*>/g, '');
}
// In Business Rule:
current.description = stripHTML(current.rich_description);
or Flow (script step)
var plainText = current.rich_description.replace(/<[^>]*>/g, '');
current.description = plainText;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 06:38 AM
Thanks for marking my solution as helpful.
Please can you mark as solution given so as to help others in the community.
Regards.