How to add approve and reject links on requested item notification?

Radhika11
Tera Contributor

Hello,

I could not figure it out a way to add the approve and reject links on the requested item email notification.

 

Could some please help?  Thanks

 

Radhika11_0-1695696314780.png

 

 

 

 

9 REPLIES 9

Bidduam
Tera Guru

Generally you would just have a mail script for an approval or a rejection that would be a link to create an email reply for either response. Or if you wanted users to approve or reject via the portal in the approval ticket you would have a link via a mail script to the approval record.

 

What we have is a button image for approve or reject saved in images within ServiceNow then we have the following mail scripts:

EG:

Give the mail script a name: approve.email.button

 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

var img = "/Approve.png";

var response = "approve";

var emailbod = "I approve this request. \r\n";

template.print(renderMailtoButton(img, response, emailbod));


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

 

 

 

Then for the reject do the same:

Give the mail script a name: reject.email.button

 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {


		  var img = "/Reject.png";

var response = "reject";

var emailbod = "I reject this request.";

template.print(renderMailtoButton(img, response, emailbod));

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

 

 

 

Then in your notification add the mail script links:

 

Click the response you wish to make

${mail_script:approve.email.button}   ${mail_script:reject.email.button}

 

Looks like this:

Bidduam_0-1695696921695.png

 

Thank you so much for helping @Bidduam 

Your buttons are very nice done.  How do I call those email scripts from sc_req_tiem?

 

Radhika11_0-1695697358437.png

 

 

 

You would need to have a notification setup on the approval table such as: (this is so when an approval request is added to a request item)

Name: Whatever you like

Table: Approval [sysapproval_approver]

Category: Service Catalog

 

When to Send:

Send When: Record inserted or updated

updated: ticked

inserted: ticked

 

Conditions:

State changes to Requested

Approval for.task type is Requested Item

Bidduam_0-1695697758641.png

 

Who will receive: 

Users/Groups in fields: Approver

Bidduam_1-1695697827811.png

 

What it will contain:

Email template: Whichever you like

Subject: Something like - Request ${sysapproval} needs your approval 

Message HTML:

Add what you want followed by the email script codes shown before.

 

 

 

 

Thank you @Bidduam 

We need approve and reject links on the sc_req_item table.  The reasons why we need those links show up there is because we don't know how to capture the variables from catalog item on to approval table.  

 

So we decided to add approve and reject on sc_req_item table.  Can this be done? If not, do you know how to we can get the variables displays on the approval table notification?