How to script the addition of approval 'escalations' while keeping the original approver?

tombialkowski
Giga Expert

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?

1 ACCEPTED SOLUTION

tombialkowski
Giga Expert

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:


find_real_file.png



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:


find_real_file.png



And then created an example workflow for the Service Request Item:


find_real_file.png


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):


find_real_file.png



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.


View solution in original post

29 REPLIES 29

actually now that i look at that. i think a better solution would be to use



"addUsersAndGroupsToApprovalList(users, groups, o)"



to add the new approvers to the existing approval.. make sure it is marked anyone can approve and wait for one to approve and you should be good to go.


This is good!!


That's what I planning on as well:



.addUsersAndGroupsToApprovalList(users, groups, o) to add the escalated approvers from the workflow after 2 days (For testing I'm using 1 min)



and I also plan on trying:



.setUserApprovalsByTask(taskID, approvalState, comment, currentStates) in the business rule to set all of the other approvals to 'not_required'.



Sadly I won't have time to try any of it until later on...


If you managed to get this working I'm all ears. I'm at a complete loss on this one:(


sumeet_n
Kilo Guru

Yes that makes it tricky. But if your workflow is such that it creates the extra approvals only after manager approval cycles then you are still safe.



If that is not the case, you need to think of -


1. using flag on approval table to identify these, OR


2. use scratchpad variable on workflow context to mark 'managerial approvals' OR


3. any other way



and let your BR on approval table use one of these to follow the logic.