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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Keri,

So the issue you are saying is that if user doesn't approve in 3 days then you set it to approved but in the mean time if user comes and manually approved the request the workflow is still stuck in the timer activity and not proceeding.

Is this your issue.

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

That's correct. The approval gets marked as Approved but the workflow does not proceed to the first catalog task. It isn't until the timer finishes that the RITM updates and moves to the task. The Approval - User task then gets changed from Approved to No Longer Required.

Hi Keri,

For this scenario you will have to split the activity using branch activity and have 2 output transition 1 for the timer and another for the wait for condition to check whether the state is approved.

Script in wait for condition:

var query = 'request_item=' + current.sys_id + '^state!=3';
var taskRecord = new GlideRecord('sc_req_item');
taskRecord.addEncodedQuery(query);
taskRecord.query();
if(taskRecord.next()){
answer = false;
}
else{
answer = true;
}

whenever the user approves manually the wait for condition will evaluate to true and workflow will proceed.

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Is this Wait for Condition its own item, or is this in place of the Condition based script on the Approval - User task? If it's it's own item, what is it supposed to tie to? And does the branch need to go to the Timer, Wait, and the Approval?

In case it helps, here's what we have created in the workflow.

find_real_file.png