Click Approve/Reject on email Notification

Al-jhon
Kilo Sage

Hello All,


I have a problem with approving/rejecting a Approval request using email notification.

Aljhon_0-1673328012194.png


When the 1st approver click the hyperlink "Click here to Approve/Reject", it will open and redirected to the approval form.

when the 2nd and 3rd approver click the same link, it will open and redirected to the approval form but under the 1st approver view or name.

Aljhon_1-1673328249419.png


Please help to check and correct my existing email script:

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

var baseURL = '';

baseURL = "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=' + baseURL + '>Click here to Approve/Reject</a><br />');


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


The link should be open and redirected under for each approver not only under the 1st approver.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Al-jhon 

your approval email notification should be on sysapproval_approver so that it sends 3 different emails for each of those 3 approver users

Condition: current.source_table == 'pm_project_task'

you can access the task fields using dot walking and show in email body

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

19 REPLIES 19

Ankur Bawiskar
Tera Patron
Tera Patron

@Al-jhon 

your approval email notification should be on sysapproval_approver so that it sends 3 different emails for each of those 3 approver users

Condition: current.source_table == 'pm_project_task'

you can access the task fields using dot walking and show in email body

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello @Ankur Bawiskar ,

How can i show the description in the email body from pm_project_task table via dot walking?

@Al-jhon 

if dot walking doesn't work you can get project task sysId and query the table and get field values

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello @Ankur Bawiskar ,

 i want to print the current project task number on the email body but my script is not working.

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

var ptaskNumber = new GlideRecord('pm_project_task');

ptaskNumber.addQuery('number', current.sysid);
ptaskNumber.query();

if(ptaskNumber.next()){
template.print(ptaskNumber.getDisplayValue());
}

// Add your code here

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


Could you please help?

Hello @Ankur Bawiskar ,

 

I got it already by adding 'task.number', current.sysid


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

var ptaskNumber = new GlideRecord('pm_project_task');

ptaskNumber.addQuery('task.number', current.sysid);
ptaskNumber.query();

if(ptaskNumber.next()){
template.print(ptaskNumber.number.getDisplayValue());
}

// Add your code here

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