How to convert HTML field value to String value for Description field from catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2024 08:33 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2024 10:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2024 10:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2024 11:11 AM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 05:38 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 05:47 AM - edited ‎04-25-2024 07:04 AM
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!