Converting HTML content of an field in a table to Plain Text of another table

mazin690
Tera Contributor

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

 

14 REPLIES 14

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.

 

mazin690
Tera Contributor

find_real_file.png

email content is my plain text field in demo table

test is html field in incident form

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();
}

Even after running the script in background , please find below for the screen shot