We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

how to use variable input as hyperlink in email notification

Kiruthika J
Tera Contributor

Hi All,

I have variable in my catalog item which is single line text and it input value contains url and in email notification I want to use that input as hyperlink for the word URL.

Sample:

KiruthikaJ_0-1763201592377.png


Thank you!!

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@Kiruthika J 

create email script and include that in your notification body like this

${mail_script:mailScriptName}

Email script

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

    // Add your code here
    template.print('<a href="' + current.variables.variableName + '">Click here to view link</href>');


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

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Kiruthika J 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Kiruthika J 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

prerna_sh
Tera Sage

Hi @Kiruthika J 
To do so, use "Email Script", then use that email script in your Notification.
Email Script:

(function runMailScript(current, template, email, email_action, event) {

      template.print('<a href="' + current.variables.variableName + '" target="_blank"> Click Here </a>');

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


To use this email script in your notification, add this as

${mail_script:<<name of the script you created>>} 


Also check out this:

https://www.youtube.com/watch?v=PpWMFORUsv0
-------------------------------------------------------------------------------------------------------------------------------------------
If my response solves your query, please marked helpful by selecting accept as Solution and Helpful. Let me know if anything else is required.
Thanks,
Prerna