How to convert HTML field value to String value for Description field from catalog item

SM123
Tera Expert

Hi,

URGENT : I have a business rule for to populate description field from catalog item to service request form. but the problem is the description field from catalog item is html type so when i populate it in service request form it is showing value in html form. could anyone help me how to resolve this? what script should i add on to this? 

provided the BR i used below

 

 

19 REPLIES 19

Hi @Ranjit Nimbalka ,

For this catalog item it combined everything. 

please check below ss:

Hi @SM123 

one more try please try below line:-

current.description = gr.cat_item.description.replace(/<(?:.|\n)*?>/gm, '');

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Ranjit

 

Hi @Ranjit Nimbalka , 

I'm still facing the spacing issue. I think @Sandeep Rajput (first comment)commented same script as you.

Please check the below ss:

Hi @Amit Pandey , 

URGENT : My team lead said the same thing about current.update in BR .. So could you please help me modify this code so it can work fine without current.update. 

@Sandeep Rajput @Ranjit Nimbalka @Karunakaran 

Please look into it :

(function executeRule(current, previous /*null when async*/ ) {
 
    // Add your code here
    var gr = new GlideRecord('sc_req_item');
    gr.addQuery('request', current.sys_id);
    gr.query();
 
    if (gr.next()) {
        var description = gr.cat_item.description;
        current.description =  new GlideSPScriptable().stripHTML(gr.cat_item.description);
       current.update();
    }
 
})(current, previous);

 

Nikhil Soni 007
Giga Guru

Hi,

 

Can you please try this line

 

we can take help of code tag as best practice instead of using regex.

 

current.description = '[code]'+gr.cat_item.description;

 

please mark this ✅ accepted If it's helpful!