Email notification not working on approval table

Hari1
Mega Sage

Hi,

I have a requirement to trigger a notification once the approver approves the approval request on the RITM(sc_req_item) table. I am triggering an event from the workflow.

I need the notification to be received by all the approvers and the requested for user.

The workflow table is RITM(sc_req_item) and i have created a run script on the workflow to trigger and event. Below is the Run script on the workflow.

var approverList = [];

approverList.push(current.requested_for);

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
while (gr.next()) {
    gs.log("Workflow Values - Inside while");
    approverList.push(gr.getValue('approver'));
}

gs.log("Workflow Values - approverList:" + approverList);

gs.eventQueue('get_server_updation',gr,approverList);

Below is the notification.

find_real_file.png

I need the notification to be triggered for all the approvers and the requested for and on the notification needs to have the approver name on the subject line. Hence I have added the above script on the advance condition on the notification.

find_real_file.png

The mail is getting triggered for all the approvers and the requested for but on the subject the approver name is a different approver name. I am not getting the approver name who has approved the request.

2 REPLIES 2

Manisha Bhakhar
ServiceNow Employee
ServiceNow Employee

Hi Hari,

Try this:

- Write an email script:

(function runMailScript(current, template, email, email_action, event) {

var approval_for = current.sysapproval.number.toString();

var approval_by = current.approver.name.toString()

email.setSubject(approval_for + " was approved by " +approval_by);

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

 

- Call this email script in notification like this ${mail_script:<Email script name>}

 

Thank you,

Manisha

Mark correct or helpful if it helps you.

Manisha Bhakhar
ServiceNow Employee
ServiceNow Employee

Hi,

Just circling back regarding your question. Did you implement the changes advised in my response?

To help others, please mark my response correct and/or helpful.

Thanks,
Manisha