How to remove HTML tags from Description field using "Client Script".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 11:59 PM
Hello,
I am trying to remove HTML Tags from Description field using Client Script. I can able to do with Business Rule, but as per my requirement i want to do it only with "Client Script".
Can anyone suggest me how to remove HTML Tags from Description field using Client Script.
Thanks in advance.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 12:07 AM
Hi,
Kindly refer this it will help you.
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 12:21 AM
Hello Kunal,
I am using the below code in my Client Script, but its not working.
function onLoad() {
//Type appropriate comment here, and begin script below
var a = g_form.getValue('description');
var b = a.replace(/<\/?[^>]+(>|$)/g, "");
g_form.setValue(b);
}
Thanks & Regards,
S.Swaroop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 12:15 AM
Hi Swaroop,
Is description field a html field? if yes then why you want html tags to be removed;
if it is string field then why html tags are added to it as it doesn't make any sense adding those
Can you provide details on above
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 12:20 AM
Hello Ankur,
Thanks for the quick response.
Description field is "String" type and data coming to "Description" field is from another HTML field. While data getting updated from HTML field to "Description" field, it was coming with HTML tags. So, i want to remove those HTML tags using "Onload" client script.
Thanks & Regards,
S.Swaroop.