Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to add approve and reject action link in email template

rmaroti
Tera Contributor

Hi everyone,

I want to add/show associated approval "Approve" and "Reject" action on email template in the notification.

 

How we can implement can anyone tell me from start to end steps.

3 REPLIES 3

Robbie
Kilo Patron
Kilo Patron

Hi @rmaroti,

 

This is quite a common question and request. So as to not reinvent the wheel, check the following link which provides a couple of responses from current MVP's with a nice walk through via video as well as a 'nicer' customer UX option.

 

https://www.servicenow.com/community/hrsd-forum/approve-reject-button-on-email-notification/m-p/1329...

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

Robert H
Mega Sage

Hello @rmaroti ,

 

I assume that this is about some process that does not trigger the regular Approval [sysapproval_approver] records, since those would already trigger the kind of email notification you are looking for.

 

The general steps to configure this are:

 

1. Go to System Notification > Email > Templates and create a template, like this:

 

Name: choose a name, e.g. "approval.action"

Subject:  Re:${number} - approve

Message: Click here to approve ${number}

 

Then create another template, but for rejection. I assume the record that is to be approved has a field called Number; if not then change to something else that is unique.

 

2. Put this somewhere in your Notification's "Message HTML" field:

 

${mailto:approval.action}

${mailto:rejection.action}

 

This will make the email contain the links for approving/rejecting, just like the OOTB approval notifications.

But you also need to make sure that the approver's email response is processed, so a last step is required:

 

3. Go to System Policy > Email > Inbound Action and create a new Inbound Email Action:

 

Name: choose a name

Target table: choose the table that the notification is about

Action type: Record Action

When to run > Type: Reply

Actions > Script: this depends entirely on what shall happen when an approval or a rejection for that particular table/application is received, so the following code is just an example and needs to be adjusted as per your requirements

if (email.subject.indexOf("approve") >= 0) {
	current.state = "approved";
}

if (email.subject.indexOf("reject") >= 0) {
	current.state = "rejected";
}

current.comments = "reply from: " + email.from + "\n\n" + email.body_text;
current.update();

 

Regards,

Robert

J Siva
Kilo Patron
Kilo Patron