logo

NJP

Approval / Reject Email and its template along with Button in Email

Import · Mar 15, 2019 · article

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.

image

  • 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('

'); template.print('${number} - ${short_description}'); template.print('

');

})(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('

Fullfiller View Only

');

template.print('

Please click the link below to access Approval Request or Request Item.

');

baseURL1 = "https://"+gs.getProperty('instance_name') + ".service-now.com/sysapproval_approver.do?sys_id="+current.sys_id;

template.print('Click here to view Approval Request
');

baseURL2 = "https://"+gs.getProperty('instance_name') + ".service-now.com/sc_req_item.do?sys_id="+current.sysapproval;

template.print('Click here to view Requested Item
');

baseURL = "https://"+gs.getProperty('instance_name') + ".service-now.com/";

appr = 'sysapproval_approver_list.do?sysparm_query=approver%3Djavascript%3AgetMyApprovals()%5Estate%3Drequested';

template.print(' Click here to view all your approvals');

})(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 == "" || item_name == "" || item_name == "")

{

template.print('

');

template.print('

');

template.print('

');

template.print('

');template.print('
');

template.print('

');

template.print('

');

template.print('

'); template.print('
');

template.print('

');

template.print('

');

template.print('

');

template.print('


');

template.print('

');

template.print('

');

template.print('

Requested For :'+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'
Requester :'+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'
Group Name : '+current.u_short_description+'
');

}

if(item_name == "7fc64ac813e3c780b43fbcaf3244b0ee" || item_name == "8d88ce4c13e3c780b43fbcaf3244b018")

{

template.print('

');

template.print('

');

template.print('

');

template.print('

'); template.print('
');

template.print('

');

template.print('

');

template.print('

'); template.print('
');

template.print('

');

template.print('

');

template.print('

');

template.print('


');

template.print('

');

template.print('

');

template.print('

Requested For :'+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'
Requester :'+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'
Template Name : '+current.sysapproval.ref_sc_req_item.variables.temp_name+'
');

}

if(item_name == "")

{

template.print('

');

template.print('

');

template.print('

');

template.print('

');

template.print('


');

template.print('

');

template.print('

');

template.print('

');

template.print('


');

template.print('

');

template.print('

');

template.print('

');

template.print('


');

template.print('

');

template.print('

');

template.print('

Requested For : '+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'
Requester : '+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'
Profile Name : '+current.sysapproval.ref_sc_req_item.variables.u_position_profile.getDisplayValue()+'
');

}

if(item_name == "28583038137e8300b43fbcaf3244b0d7" || item_name == "b285535c13224f000f315d622244b06d" || item_name == "ab1d0961130326000f315d622244b001" || item_name == "56b11d25130326000f315d622244b08e" || item_name == "8bbb25a5134326000f315d622244b0d5" || item_name == "371e383f13da8b000f315d622244b017")

{

template.print('

');

template.print('

');

template.print('

');

template.print('

');

template.print('


');

template.print('

');

template.print('

');

template.print('

');

template.print('


');

template.print('

');

template.print('

');

template.print('

Requested For : '+current.sysapproval.ref_sc_req_item.variables.requested_for.getDisplayValue()+'
Requester : '+current.sysapproval.ref_sc_req_item.variables.requestor.getDisplayValue()+'
');

}

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

  • XYZ_mailto_approval
  • XYZ_mailto_Reject
  • Approval /Reject Template

XYZ_mailto_approval

Table: sysapproval_approver

Subject: Re:${sysapproval} – approve

Message:

Approve

XYZ_mailto_Reject

Table: sysapproval_approver

Subject: Re:${sysapproval} – reject

Message:

Reject

Approval /Reject Template

Table: sysapproval_approver

Subject: ${sysapproval} Approval Request for ${sysapproval.cat_item}

Message:

${mail\_script:Notification\_header}Dear Business Owner \\ Backup Business Owner,

You have been sent the following request for approval. Please check below for details.${mail\_script:XYZ\_Approval\_script}
Approve or Reject this Request using the buttons below.

When rejecting an access request, please include the reason for rejection in the response email.
 
${mailto:XYZ\_mailto.approval}   ${mailto:XYZ\_mailto.rejection}
${mail\_script:RequestItemVaraibles}

${mail\_script:XYZ\_Approval Link}

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

View original source

https://www.servicenow.com/community/now-platform-articles/approval-reject-email-and-its-template-along-with-button-in/ta-p/2304904