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-15-2019 01:29 AM
Hello mazin,
If you run this code, it will NOT strip the HTML tags. They will be stored as a string in your plain text field in your database with all HTML tags intact.
I just ran this code in my dev instance and its working fine. Short_description of incident records contains html recores and they are stored as is in my new table field u_plain_text which has datatype String.
var gr=new GlideRecord("incident");
gr.addQuery("sys_id","a9e428cac61122760075710592216c58");
gr.query();
if(gr.next()) {
var gr1=new GlideRecord("u_testing");
gr1.initialize();
gr1.u_plain_text=gr.short_description;
gr1.insert();
}
If not working at your end, kindly share the table structure of your new table once.
Mark answer as correct once worked at your end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2019 02:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2019 02:27 AM
email content is my plain text field in demo table
test is html field in incident form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2019 02:31 AM
Hi Mazin,
Can you share the table structure of your new table. Looks like you share the same screenshot twice in your earlier thread.
And still, what is the issue you are facing when you execute the above code? Are you getting any error?
Run this in background script by changing the field names and values and let me know.
var gr=new GlideRecord("incident");
gr.addQuery("sys_id","a9e428cac61122760075710592216c58");
gr.query();
if(gr.next()) {
var gr1=new GlideRecord("u_testing");
gr1.initialize();
gr1.u_plain_text=gr.short_description;
gr1.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2019 02:41 AM