How to convert Pointer HTML Field value to Pointer String for description field from catalog item.

SM123
Tera Expert

Hi,

URGENT: I have two business rules for to populate description field from catalog item to service request form. 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. so, to eliminate that i used FIRST BR when field value is paragraph it is working fine but the problem is when field value is pointer as shown in (pic1) it is populating value in paragraph itself(pic2). when i use SECOND BR it is populating with so much spaces as shown in (pic3) and whenever there is apostrophe like (you're) it is populating something like (you're). could anyone help me how to resolve this? what script should i add on to this? 

provided the 2 BR i used below, both are before insert BRs:

(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 = gr.cat_item.description.replace(/<(?:.|\n)*?>/gm, '');
      
    }
 
})(current, previous);
(function executeRule(current, previous /*null when async*/ ) {
 
    // Add your code here
    var serviceRequestItem = new GlideRecord('sc_req_item');
    serviceRequestItem.addQuery('request', current.sys_id);
    serviceRequestItem.query();
 
    if (serviceRequestItem.next()) {
        var description = serviceRequestItem.cat_item.description;
        current.description =  new GlideSPScriptable().stripHTML(serviceRequestItem.cat_item.description);
      
    }
 
})(current, previous);

 

2 REPLIES 2

Nikhil Soni 007
Giga Guru

use 

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

 

please mark this âœ… correct if it is helpful!

Hello @Nikhil Soni 007 ,

I have used below script. but still facing the spacing issue and missing characters.

(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()) {
        current.description = '[code]'+gr.cat_item.description;
        current.description = gr.cat_item.description.replace(/<(?:.|\n)*?>/gm, '');
      
    }
 
})(current, previous);