How to Send an email notification to individual group member, if one of the group member approve/reject the request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 03:41 AM
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.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 04:29 AM
So instead of creating an approval request for another person/group after the first has approved, you're instead expecting approval from all of them at the same time but send a sort of "reminder" after someone has approved?
Just create a business rule that is run on sysapproval_approver table for approvals that match your requirement. The BR would trigger an event when the approval is set approved and one of the parameters could contain the rest of the people who haven't approved yet. Perhaps by checking other approvals that relate to the sysapproval record and picking the recipients from there.
So basically you'd query the sysapproval_approver table for records where the sysapproval is for the same record as the one that was approved. Then you'd add the approver to an array and do this for all the other approval requests. Then you just need to pass the array as a parameter to the event and you'd be set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 04:48 AM
Thank you for the prompt reply.
Could you please help me with the script, I am not that good with scripting and my developer is also on a long vacation. If you can help me with the basic script then i would try to modify according to the requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 05:03 AM
Business rule:
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('event.name', current, approverList.toString());
I didn't test this at all, so I might have missed something but here I'm checking for records in sysapproval_approver table with condition that they are for the same record and aren't the one that is approved. Then I'm taking their email address, pushing it into an array and then setting it as a parameter 1 on the event. The parameter would look like email.address@email.com, email.address@email.com, etc.
You'd just need to create a new event and change the event.name in the script to the one you created.
You can test this of course and see what ends up in the event log as parameter 1. If it's the email addresses then it should be working OK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 05:10 AM
Thanks a lot Joni. Really glad with your prompt response. i would definitely test this and let you know the result.
Once again thank you.