buttons on email notification

Servicenow10
Kilo Guru

hi

 

i have one email notification in which i want to add approve / reject button instead of link 

like if i click on approve it should automatically approve the ritm 

 

how to achieve this

thanks in advance!!

1 ACCEPTED SOLUTION

Service_RNow
Mega Sage

Hi User,

Please follow below link or stepd

https://community.servicenow.com/community?id=community_article&sys_id=5e5965c8dbd4b7c04819fb243996190f

 

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.

 find_real_file.png

  1. 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);

  1. 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;">&nbsp;</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">&nbsp;</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)

 

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy.

Thanks,

View solution in original post

11 REPLIES 11

Tejaswini9
Tera Expert

Hello Deepthi,

 

Can you please help me out, if u have done this please.

 

thank you!!!

 

its a very old post i would suggest you to post this in community our members will definitely resolve your issue also check the above links