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

kaushal_snow
Giga Sage

@Kiruthika J ,

 

 you can achieve this by creating a Mail Script (under System Notification → Email → Notification Email Scripts) that reads the catalog item variable (e.g. current.variables.your_variable_name) and prints it as an HTML link, for example.......

(function runMailScript(current, template, email, email_action, event) {
var url = current.variables.your_url_variable;
if (url) {
template.print('<a href="' + url + '" target="_blank">URL</a>');
}
})(current, template, email, email_action, event);


Then in your Notification message  you include it like this....

${mail_script:your_mail_script_name}

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Technical Consultant/Developer

PrashantLearnIT
Tera Sage

Hi @Kiruthika J 

 

This video will be super helpful for you - https://www.youtube.com/watch?v=PpWMFORUsv0

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************