Help with Auto-approval in Workflow

Keri1
Kilo Expert

On a catalog item we have a single user approval before the catalog tasks begin. To save some time and effort we're implementing a consent through silence approach after 3 business days, where if the approver takes no action the item is auto-approved. We've successfully setup the auto-approval with a timer, if statement, and Set Value, but I'm having trouble with what happens if the approver manually takes action on the request. To make sure the Approval - User task accepts the auto-approval update we have the wait for set to this condition based script:

if(current.approval == 'approved'){
    answer = 'approved';
}

Unfortunately this seems to render any manual user approve or rejects useless. Is there scripting we can add to the above or do we need to have two separate Approval - User tasks, the second using the standard "anyone approves" option? Or perhaps is there something we can do to cancel the timer if a manual approve/reject is done?

1 ACCEPTED SOLUTION

Keri1
Kilo Expert

For those interested, here's what our solution turned out to be:

find_real_file.png

 

Both the manual approval task and the timer begin at the same time. If the manual approval is approved/rejected, the request moves forward and the timer eventually runs out. The key was to add an approval action after the timer: if the manual approval had not been completed the workflow would disregard the pending approval, thus marking it as completed. The manual task would then change to "No longer required" and the workflow progressed.

View solution in original post

11 REPLIES 11

Fred Jean
Tera Expert

Hello, I have a similar requirement to auto approve after a delay.
I started implementing this using a parallel branche with a timer.

However my workflow is more complex and includes subflows which have their own approvals.

So if a user approves the first approval, the Timer branch is still active.

Then another approval is required, and this could then be auto approved because of the timer for the first approval. And this is not wanted.

As anyone come with a solution for this case ?

Only solution I can think of would be to cancel the timer activity one manually approved but this would require scripting playing with the workflow tables which is not very clean.

I'm surprised ServiceNow does not onboard an auto approval feature with a delay, or does not provide a clean way to stop a Timer.

Here's how I addressed this case :

- Before branching to the Approval and timer, a script action sets a value in the scratchpad with a name unique to the approval : workflow.scratchpad.approval1 = "requested";

- After the manual approval, I set the scratchpad value to either approved or rejected

- After the timer and before the approval actions I added an if action checking that  workflow.scratchpad.approval1 == "requested"

Then if I have another approval in the workflow that also requires auto approval, I can do the same using a different scratchpad variable name.