How to populate variable value in sc task without <p> <p/> when variable type is HTML in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 07:00 AM
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.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 09:05 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 09:24 AM
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.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 09:26 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 10:00 AM
Hi @sayyed shabana ,
Could you please refer the below article ,
write after insert BR with reference of below article,
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang