How to remove HTML Tags
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 01:35 AM
Hi Team,
I need to copy the html field to another table with string field. It copies but with HTML tags and I have around 20k records . Please help how can I remove the HTML tags. Thanks.
Thanks,
Karan
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 01:51 AM - edited 11-04-2022 01:51 AM
If you are copying it through script use:
current.getDisplayValue('html_field_name');
OR
gr.getDisplayValue('html_field_name'); // incase you are gliding that table.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 01:55 AM
Hi @KARAN24
Please refer below code for reference:
var myHTML= "<div><h1>Jimbo.</h1>\n<p>That's what she said</p></div>";
var strippedHtml = myHTML.replace(/<[^>]+>/g, '');
gs.info(strippedHtml);
Same way you can use below function to remove HTML tags and make it string.
replace(/<[^>]+>/g, ' ');
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 03:37 AM
Hello,
Please use the below:-
var regex = /( |<([^>]+)>)/ig;
var content =current.getValue("fieldname").replace(regex, " ");
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 01:31 PM - edited 04-17-2024 01:35 PM
Hello all
I am having same issue with a ui page. I have that annoying <p> showing up with my text, how do I remove/hide the <p>.
See HTML Below please