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.

html characters displays in email notification comments

Somujit1
Tera Contributor

Hi Experts,

 

I need to trigger a email notification when a knowledge article is commented from the portal. 

I have created a notification on the kb_feedback table which displays the user filled in comments in the Comments field.

In the email body i have queried ${comments}.

 

The email displays the comments but with html tags. Is there a way i can just display the user filled inputs and not the html tags.

 

Notification Body is as below -

${user} has updated a comment on the article authored by you:

${comments}

 

Attached email preview for reference 

1 ACCEPTED SOLUTION

Ahmmed Ali
Giga Sage
Giga Sage

Hello @Somujit1 

 

You can create new email script to print comments and then use that script in your notification.

Example: 

 

AhmmedAli_0-1687419799494.pngAhmmedAli_1-1687419823434.pngAhmmedAli_2-1687419863997.png

 

Mail script: 

Name: writeComments

script: 

var com = current.getValue("comments");
template.print(com);

 

 

Call script in notification: 

${mail_script:writeComments}

 

Thanks,

Ali

 

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

Thank you,
Ali

View solution in original post

4 REPLIES 4

Ahmmed Ali
Giga Sage
Giga Sage

Hello @Somujit1 

 

You can create new email script to print comments and then use that script in your notification.

Example: 

 

AhmmedAli_0-1687419799494.pngAhmmedAli_1-1687419823434.pngAhmmedAli_2-1687419863997.png

 

Mail script: 

Name: writeComments

script: 

var com = current.getValue("comments");
template.print(com);

 

 

Call script in notification: 

${mail_script:writeComments}

 

Thanks,

Ali

 

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

Thank you,
Ali

Thanks for your reply @Ahmmed Ali. It worked

Riya Verma
Kilo Sage

Hi @Somujit1 ,

Hope you are doing great.

 

you can modify your notification body in HTML preview to display only the user's input without the HTML tags:

${user} has updated a comment on the article authored by you:

${GlideStringUtil.stripHTML(${comments})}
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Thanks for your reply @Riya Verma . I tried using the GlideStringUtil with both stripHTML  as you mentioned and escapeHTML, but it didnt seem to display the comments