- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016 11:51 AM
Hi all,
We currently have a script that allows for approval escalations which flows as follows:
- Item is requested and manager approval is required.
- If 2 days goes by and the manager has not approved, escalate to the manager's manager.
- 2 days later, repeat this process and escalate to the manager's manager's manager.
The script checks to see if the next manager in the chain is a VIP:
- If the next manager is VIP, stop execution of the approval escalation workflow.
- If the next manager is NOT a VIP, continue to escalate up the chain every 2 days.
Now functionally the script is taking the old manager out of the approval record, replacing it with the manager that the approval was escalated to and calling .update(). Which means that if the original approving manager suddenly grants approval 2.5 days in, after it has escalated, the approval is discarded because that particular manager is no longer listed as an approver.
I experimented with changing .update() to .insert(), which works in the sense that both managers are listed as a potential approver. The problem is that the Request Item stands still until both approvals are received (Original Manager and any Escalated Managers).
We want to fix this so that any manager in the escalation chain can approve, and if any one person does approve, the remaining approvals are no longer required. Anyone have any thoughts or suggestions that might put me on the correct path?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2016 07:12 PM
I was reading up on workflows and remembered that workflows terminate the moment End is reached, so I came up with an alternate approach that should work very nicely, feels much cleaner, can be expanded upon and helps keep the process closer to being 'out of the box'.
First I created a new subflow called GetManagerApproval:
I then added the following variable to GetManagerApproval's subflow properties, which is assigned a yes/no value in the two run scripts (approved/rejected) just prior termination:
And then created an example workflow for the Service Request Item:
Double-clicking the GetManagerApproval activity, I set the 'Map to return value' to match the variable previously created (The If activity tests this variable for a yes/no, returned from the subflow, and acts accordingly):
It works perfectly whether I stop it at 1st, 2nd or 3rd level. And I figured there's a problem if you are having to escalate 3 or more times for approval. But if it should be needed I can simply add another layer or two into the subflow:)
Let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016 01:24 PM
on the approval table is a field for workflow activity.. by limiting your query to approvals for that item with that workflow activity you should be good to go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016 02:01 PM
I completely missed that field when I looked over the table, but that is exactly what I need to build on Sumeet's suggestion. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016 02:09 PM
no problem most people miss it <me included for the LONGEST time> the exact same field is on catalog task.... which can be helpfull when you need to specifiy an individual task in a workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016 05:17 PM
Getting closer. Once an approval is received the business rule sets any remaining 'Requested' approvals to 'No Longer Required', but the workflow for the request item isn't recognizing that approval has been received and is still awaiting manager approval. Is there some way to trigger it so that it resumes?
function onAfter(current, previous) {
var grApprovals = new GlideRecord('sysapproval_approver');
grApprovals.addQuery('sysapproval=' + current.sysapproval + '^state!=approved');
grApprovals.query();
if(grApprovals.hasNext()) {
}
while(grApprovals.next()) {
grApprovals.state = 'No Longer Required';
grApprovals.update();
}
}
I setup a generic item that requires approval from either of 2 people. When I right-click + approve any of the escalated approvals, all others are set to 'No Longer Required'. But if I approve either of the first 2 non-escalated approvals it spits out the task and continues as expected.
UPDATE: I ran across the WorkflowApprovalUtils script include. If this does what I think it does then I might be back on track on how to properly add and update approvals. Time to do some studying.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2016 07:57 AM
i was toying with this yesterday in my sandbox and that was the EXACT problem i had... getting the workflow to move past that approval box to the next step... was hoping you had that fixed on y our side already...