- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 09:34 PM
Hello Everyone,
We have ebonding in place using Scripted Rest API. The description field in the client's snow is of HTML type and mine is of string type field. This is why I am getting HTML tags in description field. How can I remove these tags?
Regards,
Amit
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 09:37 PM
Hi Amit,
Just use this function to pass your html body and it will return you content in text:
function getFinalText(text) {
// Replace all <br /> tags with a CRLF
var regX1 = /<br\s\/>/ig;
var text2 = text.replace(regX1, String.fromCharCode(13));
// Replace all remainging HTML tags with ""
var regX2 = /(<([^>]+)>)/ig;
var finalText = text2.replace(regX2, "");
return finalText;
}
Regards,
Mahesh Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 09:37 PM
Hi Amit,
Just use this function to pass your html body and it will return you content in text:
function getFinalText(text) {
// Replace all <br /> tags with a CRLF
var regX1 = /<br\s\/>/ig;
var text2 = text.replace(regX1, String.fromCharCode(13));
// Replace all remainging HTML tags with ""
var regX2 = /(<([^>]+)>)/ig;
var finalText = text2.replace(regX2, "");
return finalText;
}
Regards,
Mahesh Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 07:54 AM
Hi Mahesh,
I have 2 tags in my HTML field, <p> and <a>. I want to keep the <a> tag so that it maintains the hyperlink functionality. Can you please suggest how to remove the <p> tag and keep the <a> tag.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 09:37 PM
Use below script to parse out the html tags:
var res = str.replace(/<[^>]*>/g, '');
str is your html field value with the HTML tags
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 10:06 AM
Mahesh,
I am having this same issue with a UI action on the Project table that creates a Change Request when used. The Business Case field on Project is an HTML field type and this verbiage is getting added to the Justification field on the Change Request. All of the tags/HTML code has started showing up in the Justification field. The UI Action script is very simple, any suggestions on how to resolve this issue?
Script:
function createChange() {
var cr = new GlideRecord("change_request");
cr.short_description = current.short_description;
cr.description = current.description;
cr.justification = current.business_case;
cr.parent = current.sys_id;
var sysID = cr.insert();
var mySysID = current.update();
gs.addInfoMessage(gs.getMessage("Change Request {0} created", cr.number));
action.setRedirectURL(cr);
action.setReturnURL(current);
}