- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 01:21 PM
Hi Servicenow Community,
I am working on a flow that dumps the content of various "pills" (variables) into the description field. The issue is that they are being copied into the description field with HTML tags since they are set up as rich-text boxes on the record producer/form.
Is there a function I can use that would convert the rich-text to plain text? I looked around but there doesn't seem to be anything that would accommodate that.
Would this need to be done with a script and if so, can i use the pill picker and scripting at the same time?
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 01:26 PM
Hello @BrunoAguiar428
I just answered this question 2 mins ago by somebody else.
Use below 👇 script
var html = RICHFIELD.toString();
// Decode HTML entities using GlideStringUtil
var decoded = GlideStringUtil.unescapeHTML(html);
// Convert <br> to newline (optional), then strip all other tags
var plainText = decoded.replace(/<br\s*\/?>/gi, '\n')
.replace(/<[^>]*>/g, '');
This works perfectly.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 01:59 PM
Sure @BrunoAguiar428
Let me know if it works for anyone - means it works for all.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 09:31 AM
Hello @BrunoAguiar428
Is there any update here ?
Please confirm if you checked my answer. Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for my efforts and also it can move from unsolved bucket to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 10:47 AM
@Shivalika I ran into an issue where this seems to not be working. I'm not sure if it's because not all my variables get used when the form gets filled out or not but I get a variable not defined error. Please see my screenshot for more details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 10:56 AM
Hello @BrunoAguiar428
Can you remove that variable and see ? It may be whatever request item you have passed in testing that is not having this value or its not appropriate, but its a different issue.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 11:12 AM
@Shivalika It seems like the variables aren't getting passed in. My code looks like this:
fd_data._1__get_catalog_variables.pill_1;
fd_data._1__get_catalog_variables.pill_2;
fd_data._1__get_catalog_variables.pill_3;
fd_data._1__get_catalog_variables.pill_4;
fd_data._1__get_catalog_variables.pill_5;
fd_data._1__get_catalog_variables.pill_6;
fd_data._1__get_catalog_variables.pill_7;
var dataPills = [pill_1, pill_2, pill_3, pill_4, pill_5, pill_6, pill_7]
var stringConversion = dataPills.toString();
// Decode HTML entities using GlideStringUtil
var decoded = GlideStringUtil.unescapeHTML(stringConversion);
// Convert <br> to newline (optional), then strip all other tags
var plainText = decoded.replace(/<br\s*\/?>/gi, '\n')
.replace(/<[^>]*>/g, '');