
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎03-15-2019 01:43 AM
Hi All,
Today I am sharing knowledge of how to create or send Notification to for approval and reject using button in email.
Creating an email notification involves specifying when to send it, who receives it, what it contains, and if it can be delivered in an email digest.
Role required: admin
Consider the following items when you create or update a notification:
- Your notification recipients must be active users and have a valid email address defined.
- Your notification recipients must have the appropriate notification preferences enabled.
Use the following tabs in the Notification form to configure an email notification:
- When to send — Conditions required to send the notification.
- Who will receive — Recipients of the notification.
- What it will contain — Contents of the notification.
- What Digest will contain — Contents of the email digest if the notification can be delivered in a digest.
You will be having below email after configuring all the steps.
- Create Email Script
- Notification_header
- Approval_link
- Approval_script
Notification_header
Header you can create according to your client as they want.
(function runMailScript(current, template, email, email_action, event) {
template.print('<p><font size="6" color="#808080" face="helvetica">');
template.print('${number} - ${short_description}');
template.print('</font></p>');
})(current, template, email, email_action, event);
Approval_Link
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var baseURL1 ='',baseURL2 ='',baseURL ='', appr ='';
template.print('<p style="font-family: verdana; font-size: 14px;color: black;"><strong>Fullfiller View Only</strong></p>');
template.print('<p style="font-family: verdana; font-size: 14px;color: black;">Please click the link below to access Approval Request or Request Item. </p>');
baseURL1 = "https://"+gs.getProperty('instance_name') + ".service-now.com/sysapproval_approver.do?sys_id="+current.sys_id;
template.print('<a style="font-family: verdana; font-size: 14px;color: blue;" href='+baseURL1+'>Click here to view Approval Request</a><br />');
baseURL2 = "https://"+gs.getProperty('instance_name') + ".service-now.com/sc_req_item.do?sys_id="+current.sysapproval;
template.print('<a style="font-family: verdana; font-size: 14px;color: blue;" href='+baseURL2+'>Click here to view Requested Item</a><br />');
baseURL = "https://"+gs.getProperty('instance_name') + ".service-now.com/";
appr = 'sysapproval_approver_list.do?sysparm_query=approver%3Djavascript%3AgetMyApprovals()%5Estate%3Drequested';
template.print('<a style="font-family: verdana; font-size: 14px;color: blue;" href='+baseURL+appr+'> Click here to view all your approvals</a>');
})(current, template, email, email_action, event);
Approval_script
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var item_name= current.sysapproval.cat_item;
if(item_name == "<sys_id>" || item_name == "<sys_id>" || item_name == "<sys_id>")
{
template.print('<table border="1" style="width: 100%; background-color: #CCCCCC;font-family: verdana;font-size: 14px; color: black;">');
template.print('<tbody>');
template.print('<tr>');
template.print('<td>Requested For :</td>');template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Requester :</td>'); template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Group Name :</td>');
template.print('<td>'+current.u_short_description+'</td><br />');
template.print('</tr>');
template.print('</tbody>');
template.print('</table>');
}
if(item_name == "7fc64ac813e3c780b43fbcaf3244b0ee" || item_name == "8d88ce4c13e3c780b43fbcaf3244b018")
{
template.print('<table style="width: 100%; background-color: #CCCCCC;font-family: verdana; font-size: 14px;color: black;">');
template.print('<tbody>');
template.print('<tr>');
template.print('<td>Requested For :</td>'); template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Requester :</td>'); template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Template Name :</td>');
template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.temp_name+'</td><br />');
template.print('</tr>');
template.print('</tbody>');
template.print('</table>');
}
if(item_name == "<sys_id>")
{
template.print('<table style="width: 100%; background-color: #CCCCCC;font-family: verdana; font-size: 14px;color: black;">');
template.print('<tbody>');
template.print('<tr>');
template.print('<td>Requested For :</td>');
template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Requester :</td>');
template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Profile Name :</td>');
template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.u_position_profile.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('</tbody>');
template.print('</table>');
}
if(item_name == "28583038137e8300b43fbcaf3244b0d7" || item_name == "b285535c13224f000f315d622244b06d" || item_name == "ab1d0961130326000f315d622244b001" || item_name == "56b11d25130326000f315d622244b08e" || item_name == "8bbb25a5134326000f315d622244b0d5" || item_name == "371e383f13da8b000f315d622244b017")
{
template.print('<table style="width: 100%; background-color: #CCCCCC;font-family: verdana; font-size: 14px;color: black;">');
template.print('<tbody>');
template.print('<tr>');
template.print('<td>Requested For :</td>');
template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Requester :</td>');
template.print('<td>'+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'</td><br />');
template.print('</tr>');
template.print('</tbody>');
template.print('</table>');
}
})(current, template, email, email_action, event);
- Create Email Script
- XYZ_mailto_approval
- XYZ_mailto_Reject
- Approval /Reject Template
XYZ_mailto_approval
Table: sysapproval_approver
Subject: Re:${sysapproval} – approve
Message:
<div style="font-family: verdana; font-size: 12px;">Approve</div>
XYZ_mailto_Reject
Table: sysapproval_approver
Subject: Re:${sysapproval} – reject
Message:
<div style="font-family: verdana; font-size: 12px;">Reject</div>
Approval /Reject Template
Table: sysapproval_approver
Subject: ${sysapproval} Approval Request for ${sysapproval.cat_item}
Message:
<div style="font-family: verdana; font-size: 14px; color: black;">${mail_script:Notification_header}Dear Business Owner \ Backup Business Owner,<br /><br />You have been sent the following request for approval. Please check below for details.${mail_script:XYZ_Approval_script}<br />Approve or Reject this Request using the buttons below.<br /><br /><strong>When rejecting an access request, please include the reason for rejection in the response email.</strong></div>
<div style="font-family: verdana; font-size: 14px;"> </div>
<table style="font-family: verdana; font-size: 14px;" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;" align="center" bgcolor="#FFDE00" width="100" height="30"><a style="font-size: 12px; font-family: verdana; text-decoration: none; line-height: 25px;">${mailto:XYZ_mailto.approval}</a></td>
<td width="200" height="30"> </td>
<td style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;" align="center" bgcolor="#CCCCCC" width="100" height="30"><a style="font-size: 14px; font-family: verdana; text-decoration: none; line-height: 25px;">${mailto:XYZ_mailto.rejection}</a></td>
</tr>
</tbody>
</table>
<div style="width: 100%;">${mail_script:RequestItemVaraibles}</div>
<p>${mail_script:XYZ_Approval Link}</p>
Create Notification to access all these Scripts and template
System Notification -> Notification
Provide unique name and all related values like below;
- When to send
- Who will receive
- What it will contain
- What Digest will contain
Please don't provide any value in "what it will contain" tab apart from template you have created (Main Template)
For reference
https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/notification/task/t_CreateANotification.html
Please hit correct or mark helpful if this helped you.
Regards
Sandeep
- 12,827 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice Post Sandeep.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you 🙂
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Sandeep
When you get the approval mail and you click either approve or reject, a new email is created where you have to click send.
I am working with the idea, that the created email could be sent automatically, so you don't have to click sent. This is to avoid users from writing something extra in the mail, and make the approval a little easier.
But it seems a little difficult to figure out how that email is created and configured.
Do you have an idea about this.
thanks in advance
Br, Dan
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Dan,
Do you find any solution?
Can you share with us if you there is any solution for completely automate email response.
Regards,
Ram
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Ram
No, not yet 🙂
Regards,
Dan
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Sandeep, where do we create 2nd list of email scripts?
i.e.
XYZ_mailto_approval
Table: sysapproval_approver
Subject: Re:${sysapproval} – approve
Message:
<div style="font-family: verdana; font-size: 12px;">Approve</div>
Those are templates, right?
So, how do we call all these scripts and templates in a single notification?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Sandeep,
Do you know how can we add the cc email id when Approve/Reject button is clicked within the Notification.
Presently it open the outlook window with instance email address in To field and subject as 'Re: Approved'
in CC field I need to include specific notification when any user clicks on Approve button of the notification.
Please suggest.
Regards,
Imran
+91 9916983541