Use HTML Variable in Notification

kshaw
Giga Guru

I want to use an HTML variable from a RITM to add to a notification.

 

I know I can edit html code within the notification creation form, and I have HTML formated text in a variable but from what I understand when I reference the variable in the notification ${variable_name}, its just going to pull in plain text.

 

How can I get formatted text from the RITM into the notifcation?

3 REPLIES 3

Chaitanya ILCR
Kilo Patron

Hi @kshaw ,

notification pull the html variable and formats it

what you see in the html variable will be shown in notification as it is

 

 

ChaitanyaILCR_1-1745982006457.png

 

 

ChaitanyaILCR_0-1745982002279.png

 

if you want to format it further you can use notification email scripts and wrap the html field in the div container and add formatting to it 

ChaitanyaILCR_3-1745982543691.png

 

ChaitanyaILCR_4-1745982550739.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

 

J Siva
Tera Sage

Hi @kshaw 
You can acheive this using email script. This approach will work even of you store the HTML code in the string type field. PFB sample.

1. Catalog item with HTML variable/String variable

JSiva_0-1745982672986.png

JSiva_0-1745983172839.png

 

2. Mail script to process the HTML variable

JSiva_1-1745982710786.png

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    var html_txt = current.variables.html_variable;
    template.print(html_txt);

})(current, template, email, email_action, event);

 

3. Use the mail script in the Notification

JSiva_2-1745982780981.png

Output 1: (HTML type variable)
RITM:

JSiva_3-1745982845263.png

Email:

JSiva_4-1745982861479.png

Output 2: (Multiline text type variable)

JSiva_3-1745983323476.png

 

JSiva_2-1745983273784.png

 

Hope this helps,
Regards,
Siva

 

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@kshaw 

if you include the variable directly using the syntax ${variableName} it will respect the HTML format as shared by @Chaitanya ILCR 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader