Email other approvers that at least one approver has approved the hr case

Taza
Tera Contributor

Hi there,

 

I am trying to get the platform to "Email other approvers that at least one approver has approved the record". 

 

For example, when a recruitment hr case is raised, an (group) approval record is generated with approval records assigned to the users. the Flow is such that ALL approvers have to approve in order for the approval to be accepted.

 

My requirement is to auto send an email to the remaining group members ONCE someone in the group has approved from their end.

 

I have followed this to no avail: How to Send an email notification to individual gr... - ServiceNow Community

The event does not fire thus a notification is not triggered. 

 

I'm not sure where I'm going wrong here, i've attached a screenshot of the business rule run conditions (sysapproval_approver table) and here is the script used:

 

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here

var approverList = [];

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sysapproval);
gr.addQuery('sys_id', '!=', current.sys_id);
gr.query();

while (gr.next){
approverList.push(gr.approver.email);

}

gs.eventQueue('approval.approved.by.other', current, approverList.toString());

})(current, previous);

 

 

 

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

Did you also create the event definition for the below event? Also you BR condition doesn't look correct. It should say state changes to approved instead of state = requested.

approval.approved.by.other

 


Please mark this response as correct or helpful if it assisted you with your question.

Taza
Tera Contributor

I have indeed created the event named "approval.approved.by.other".

 

I need the email to trigger when an approver has approved it from their side so that the notification is sent to the remaining approvers. If I change the condiiton to state changes to approved, it would only fire the event once everyone has approved right?

No. Every user will have an individual sysapproval_approver record linked to a Group Approval. So you need to have the condition state changes to Approved, in order for the BR to know that one approver has approved.


Please mark this response as correct or helpful if it assisted you with your question.

Taza
Tera Contributor

I'll give this a go thanks