Converting HTML content of an field in a table to Plain Text of another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 10:49 PM
How to convert the HTML content of an field from my incident form to the custom table (New Table) field which is Plain text?
Incident html field (u_Htext) - Type -- HTML
custom table field - (u_description) -- Type -- String
Any idea will be appreciatable
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 11:01 PM
Hi Mazin,
When you say convert, do you want to strip the HTML tags before storing into the custom table field? If yes, then you can simply strip them like this.
var gr=new GlideRecord("incident");
gr.addQuery("sys_id",incident_sys_id);
gr.query();
if(gr.next()) {
var str=gr.u_Htext;
var strip_html = str.replace(/(<([^>]+)>)/ig,"");
current.u_description = strip_html;
current.update();
}
Mark the comment as correct if this solves.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 11:52 PM
Hi Asif,
I want the whole content which is their in HTML format in incident table field.. it should accept the same in the plain text field... it is not just fetching the text from it... like formating has to be retained in plain text field..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 11:55 PM
So what issue are you facing when you try to store it directly
var str=gr.u_Htext;
current.u_description =str.toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2019 01:19 AM
i dont want to strip off the html tag .... i wnt the same format whtever is present in the html field.. same has to be captured in the plain text field.. because plain text field is not accepting the HTML content... not just the text ... i need the whole content in the plain text field.