How to conditionally add a button to email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2023 09:23 AM
I'm trying to create a button in an email notification that links to the SLA ticket. I currently have an email script for a "button bar" that contains buttons linking to the ticket, SN and a KB article. Just trying to only add an SLA ticket link button when the email notification is for an SLA breach or warning.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 12:41 AM
You can have the condition in your notification email script and perform a template.print based on if the condition has been satisfied or not.
For example:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var emailBody = '<button>Go to ticket</button>';
if (event.parm1 == 'Closed') {
emailBody += '<button href = https://www.' + gs.getProperty('instance_name') + '.service-now.com/>Go to SLA Ticket</button>';
}
})(current, template, email, email_action, event);
Please mark the solution accepted or helpful so that it can be referred in case anyone else has similar question in future.
Regards,
Vismit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 04:49 AM
Hi, I recommend using the change ticket approval notification template as a reference. Use the same logic for your requirements.
Suresh.