In scripted Get API we are sending the sc_task catalog item description but it contains HTML text

Mudugal Akhil
Tera Contributor

Need  to send the catalog item description from sctask table,that is being sent as below but we need to send without HTML tags i.e plain text 

 

"cat_item.description": "<p>Review has been configured.</p>",

 

Need to send above as 

"cat_item.description": "Review has been configured.",

 
few other it is going as  below can we modify it text only 

 

  "cat_item.description": "<p>Request account access for a system user. <a title=\"Click here\" href=\"https://pages.servicenow.com/download/attachments/280699946/vcb.xlsm\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">Click here</a><span style=\"background-color: rgb(var(--sn-tinymce_content-background,var(--now-form-field--background-color,var(--now-color_background--primary,var(--now-color--neutral-0,255,255,255))))); color: rgb(var(--sn-tinymce_content-text,var(--now-form-field--color,var(--now-color_text--primary,var(--now-color--neutral-18,22,27,28)))));\"> to download the template.</span></p>",

as 

  "cat_item.description": "Request account access for a user. to download the template.",

Do we have any OOTB method to convert this ?

 

1 ACCEPTED SOLUTION

swathisarang98
Giga Sage
Giga Sage

Hi @Mudugal Akhil ,

 

You can refer the below article to add hyperlink in description,

https://www.servicenow.com/community/developer-forum/how-to-create-a-hyperlink-with-the-variable-typ... 

 

if you want to remove p tag then you can 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

 

 

View solution in original post

6 REPLIES 6

swathisarang98
Giga Sage
Giga Sage

Hi @Mudugal Akhil ,

 

You can refer the below article to add hyperlink in description,

https://www.servicenow.com/community/developer-forum/how-to-create-a-hyperlink-with-the-variable-typ... 

 

if you want to remove p tag then you can 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

 

 

Hi @swathisarang98
Thanks for the reply .
I have tried your workaround it is working.

Thanks 

Andrew_TND
Mega Sage
Mega Sage

Hi @Mudugal Akhil 

Without reviewing your entire API I'm taking a shot in the dark... Try something like this.

var catdescription = "cat_item.description": "<p> Review has been configured.</p>" 
var plaintext = catdescription.replace(/<[^>]+>/g, '');
console.log(plaintext);

 Please mark as helpful or if its resolved the issue, CORRECT!

Hi @Andrew_TND 
Thanks for the reply .
I have tried your workaround it is working.

Thanks