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

Narsing1
Mega Sage

Can you try like this

var st = "<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>";
gs.print(st.replace(/<[^>]*>?/gm, ''));

Narsing1_0-1709107870480.png

 

Thanks,

Narsing

@Narsing1 Thanks for the reply got the solution above.