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

Hi Raymond,



Thanks for the suggestion.I tried to add a run script with this script but unfortunately, it didn't work.  



setUserApprovalsByGroup(groupID, approvalState, comment, ['not requested', 'not_required', 'requested']);



I've added approval action by setting action to "Disregards pending approvals" and its working perfectly fine now!




Hi,

 

This is working great.  However, my end activity is showing as undefined.  I have put in the script for approved as follows:

workflow.scratchpad.subflow_approved = 'approved';
gs.log("Stacy's getManagerWorkflow end activity " + workflow.scractchpad.subflow_approved);

My log says undefined.

I did create the variable in the getManagerApproval workflow and I changed it from yes/no to single line text.

Do I need to create the same variable on my Parent workflow?

Thank you for your help.

Stacy

Hi,

This is a great idea I aa going to try it.

Can you please tell me what are you doing in your final run scripts at the end of the workflow where you are setting the workflow approved or rejected.  What does that script look like?

Thanks,

Stacy

atul3
Kilo Contributor

Hi Tom,



"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)."



how did you manage to list all the approvers in the list. I am able to generate dynamic approvers everytime but as soon as next level approver gets in, it updates the previous record.



Could you please help me with this problem?



Thanks & Regards,


Atul Chauhan


Navigate to Workflow > Administration > Activity Definitions, and open the 'Approval - User' activity. Line 118 in the code performs a check to drop all previously listed approvers. I did not like this at all, and I didn't want to modify the out of box functionality, so I instead:


  1. Navigate to Is it possible to clone a workflow activity definition with all activity variables
  2. Follow the steps to clone the 'Approval - User' activity (Will appear in the workflow editor with whatever new name you give it.
  3. Comment out line 118 on the cloned version of the 'Approval - User' activity.


I then built my workflow to loop back around and provide an update list of sys_id's, which I keep stored on the scratchpad (workflow.scratchpad,approvalChainIds) as a comma separated list.



With the cloned activity the original approvers will be left on the list, and any new users will be added (NOTE: If you remove a user from your list of sys_id's it will remove them as an approver, giving you full control over the removal of users from the list).



Hope this helps!:)