Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to populate variable value in sc task without <p> <p/> when variable type is HTML in servicenow

sayyed shabana
Tera Contributor

Hello All,

Need help on this query.

I am trying to populate 1 variable value in SCtask , the variable value is showing properly in RITM values not like html tags, but in SCtask showing like below.
tried with workflow script but no use.

sayyedshabana_0-1710165522892.png

 

Thanks in advance

4 REPLIES 4

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @sayyed shabana ,

 

Use below code eaxmple to strip the html part from variable values:

  var gr = new GlideRecord('sc_req_item');
 gr.addQuery('sys_id', '48841ffe1bbc0610ae2163142a4bcbb3')   // use the sys_id of your RITM record.
 gr.query();
 if(gr.next()){
var htmlValue= gr.variables.additional_details.toString();     // use your variable
gs.print('Original '+htmlValue);

// use any of the example below
// example NO: 1
var output= htmlValue.replace(/<\/?[^>]+(>|$)/g, "");    
gs.info('html output: '+ output)
// example NO : 2
gs.info('html sanitized:'+  GlideSPScriptable().stripHTML(htmlValue));
}

 

Let me know if this works for you!!

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh

Aman Kumar S
Kilo Patron

Hi @sayyed shabana 

Can you check your dictionary override for description field for sc_Req_item and sc_Task table and check if html_sanitize attribute is added there, if not add the attribute for the sc_Task table, it will work as expected.

AmanKumarS_0-1710174244570.png

 

Best Regards
Aman Kumar

Sumanth16
Kilo Patron

Hi @sayyed shabana ,

 

Please refer to thread:

https://www.servicenow.com/community/developer-forum/variable-data-to-html-type-variable/m-p/1363141

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

swathisarang98
Giga Sage

Hi @sayyed shabana ,

 

Could you please refer the below article ,

write after insert BR with reference of below article,

https://www.servicenow.com/community/developer-forum/script-catalog-items-description-to-request-wit... 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang