How to Send an email notification to individual group member, if one of the group member approve/reject the request.

sashichand
Mega Expert

We came with a requirement, When a request is logged it would go for 3 level of approvals (Apprver1 approved, then it should go to Approver2, and so on (we have 5 approvers), which can achieved if we can create a three lever approval in workflow. But we can't amend/change anything in the Workflow.

Our instance is designed for only one level of approval, either a Line manager or a group approval.

 Workaround we are thinking is:

 So we are going with group approval (total of 5 approves from different teams), everyone should approve, as usual an approval email will trigger to each of the group members as soon the request is logged.

 Now, we should send a notification emails (via Business rule/event) to individual group members. Suppose Apprver1 has approved, so I want to send an email to other group members (Apprver2, Appover3 like that we have 5 approvers), saying Apprver1 has approved this request.

 Is there any possibility to achieve like this, or any other work-around? Please note we can’t modify the existing workflow.

 

 

9 REPLIES 9

Hi Joni,

hope you are doing great? i am here again seeking your help, have a slight modification in the requirement.

1> First, i log a request. 
2> Approval goes to Appover 1, once he approves then 4 group approvals will generate.
3> Group 1, 2, 3, 4 all has 2 users each.

Till here its all fine. They can approve all seems fine. 

But now need help for this part: i have to notify the groups.
4> Now if any one users from any group approves, i want to send an email to remaining group
members, stating that the Group 1/2/3/4 has approved, its pending with your approval.

i have a After BR written and triggered an event to send the notification. But its not working.

Here is my Code: Need your help

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

// Add your code here
var gr= new GlideRecord('sysapproval_group');

gr.addQuery('sysapproval',current.getValue('sys_id'));

gr.addQuery('state',current.approved);

gr.query();

while(gr.next()){

if(gs.getUser().getUserByID(gr.getValue('approver')).isMemberOf("group 1")){

gs.eventQueue("TriggerEvent"); //log event here
}
}

})(current, previous);

sashichand
Mega Expert
Hi Joni, hope you are doing great? i am here again seeking your help, have a slight modification in the requirement. 1> First, i log a request. 2> Approval goes to Appover 1, once he approves then 4 group approvals will generate. 3> Group 1, 2, 3, 4 all has 2 users each. Till here its all fine. They can approve all seems fine. But now need help for this part: i have to notify the groups. 4> Now if any one users from any group approves, i want to send an email to remaining group members, stating that the Group 1/2/3/4 has approved, its pending with your approval. i have a After BR written and triggered an event to send the notification. But its not working. Here is my Code: Need your help (function executeRule(current, previous /*null when async*/) { // Add your code here var gr= new GlideRecord('sysapproval_group'); gr.addQuery('sysapproval',current.getValue('sys_id')); gr.addQuery('state',current.approved); gr.query(); while(gr.next()){ if(gs.getUser().getUserByID(gr.getValue('approver')).isMemberOf("group 1")){ gs.eventQueue("TriggerEvent"); //log event here } } })(current, previous);

Hi,

assuming you have written this BR on table sysapproval_group

try making the following changes to the script

- instead of using sysapproval , use 'parent'

- change state to 'approval' and current.approval

 

ex - 

(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr= new GlideRecord('sysapproval_group');
gr.addQuery('parent',current.getValue('sys_id'));
gr.addQuery('approval',current.approval);
gr.query();
while(gr.next()){
if(gs.getUser().getUserByID(gr.getValue('approver')).isMemberOf("group 1")){
gs.eventQueue("TriggerEvent"); //log event here
}
}

Hi rad,

 

I have written the BR on the sc_req_item table. Coz i have to query for the particular item/Requested items in the sysapproval_group table.

If i write the BR on the group approval table then how can i query the particular RITM inside the group approval table.

`4> Now if any one users from any group approves, i want to send an email to remaining group members, stating that the Group 1/2/3/4 has approved, its pending with your approval.`

 

shouldnt the BR be on the sysapproval_group table since we are checking after one group has approved.

You can get the sys_id from the parent field