The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Description field type from HTML to String

Deepa Karthiga
Tera Contributor

Hi,

For a requirement, we changed the field type of Description from String to html and used for few days. But now we decided to change it back to String type.

The problem here is when we changed back to String, we see some tags in the existing record of incident, change, ritm and other task tables description(populated when the field type was html) field. Please help to resolve this.

Thanks in advance.

-Deepa

 

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

Below code converts HTML string to a text string. You need to run this code for subset of records and update the text string into that field

 

var gr = new GlideRecord('task');
gr.get('sys_id');
var htmlDesc = gr.description.getDisplayValue();

var txtDesc = htmlDesc.replace(/<(?:.|\n)*?>/gm, '');

gs.print(txtDesc);

View solution in original post

10 REPLIES 10

Gurpreet07
Mega Sage

Below code converts HTML string to a text string. You need to run this code for subset of records and update the text string into that field

 

var gr = new GlideRecord('task');
gr.get('sys_id');
var htmlDesc = gr.description.getDisplayValue();

var txtDesc = htmlDesc.replace(/<(?:.|\n)*?>/gm, '');

gs.print(txtDesc);

Hi Gurpreet,

It worked, thank you :-).

Is there a way to convert plain text to html?

 

- Deepa

There's no such thing as there could be many possibilities of applying HTML to a plain text field...

Thank you.