- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2017 11:33 AM
hello All,
I have a trouble removing html tags, Please read the below details and suggest the best solution.
I have a table when i select a particular template it is displaying the whole message with the html tags, I don't want the tags to be appeared on the message content. where the good part is when I press send mail the HTML tags are removed and the original message is displayed on the outlook.
Major requirement is i don't want to c the message with HTML tags on the message box when a template is selected. Please suggest a best solution, Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2017 12:17 PM
Hi Prajwal ,
You can create a new field on you table and copy the HTML text to that filed using the below script.
You have to run this as a background script.
var so=new GlideRecord('-----------------'); //your table name
so.addNotNullQuery('-------------------'); //HTML field name or add a query condition as per your requirement.
so.query();
while(so.next())
{
var a= so.unit_description.getXHTMLValue();
a= a.replace(/&(lt|gt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">";
});
var b = a.replace(/<\/?[^>]+(>|$)/g, "");
so.setDisplayValue('----------------------',b); // New field name
so.update();
}
- Please like or mark as correct/helpful as you see fit.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2017 11:37 AM
Hi Prajwal,
Is Email Client is a custom table? You should have had the message field as an HTML field, so that the HTML tags wont be visible.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2017 12:01 PM
Hello Sanjiv,
No it is not, Where do you want me to check the message field as HTML field..???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2017 12:08 PM
The dictionary type is probably currently a String and you need to change it to HTML so it correctly reads the HTML tags and displays it so it is readable. However if you want to truely strip the HTML formatting you could do soemthign like this:
var html = "put your message with tags here";
var div = document.createElement("div");
div.innerHTML = html;
var text = div.textContent || div.innerText || "";
g_form.setValue('message', text) ;
or use RegEx to strip it
cleanText = message_field.replace(/<\/?[^>]+(>|$)/g, "");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 10:53 AM
Is there a way to keep html tags from displaying in the service portal? I am displaying content from some html fields I created on a table and it is including the html tags! Thanks.