How to cancel a workflow timer

Keri1
Kilo Expert

We have a "consent through silence" approach in our workflows where the system owner has 3 days to approve a RITM before it is auto-approved. The potential issue is what happens if the RITM is manually approved. Later in the workflow we have a Join activity that gets hung up because the timer is still running. While I don't think most requests will get done before the timer ends, we want to be sure it doesn't become an issue in production. I'm not sure what we could put in the workflow or a business rule to cancel this timer; any suggestions?

find_real_file.png

1 ACCEPTED SOLUTION

Keri1
Kilo Expert

My coworker was able to use feedback from another post to come up with a solution. Sharing in case it helps others.

In the workflow we added a Run Script after the approval task that runs if the task is marked approved. The script then checks the ongoing activities based on name and it's activity index # to see if it exists and delete it. For our workflows the index # could vary so there has to be an Or condition to check more than one possibility.

 

var wf = new GlideRecord("wf_context");
wf.addQuery('sys_id', current.context);
wf.query();
while (wf.next())
{
    var wfe = new GlideRecord("wf_executing");
    wfe.addQuery('context', wf.sys_id);
    wfe.addQuery(activity.getDisplayValue(); "Activity Name");
    var qc = wfe.addQuery('activity_index', #);
    qc.addOrCondition('activity_index, #);
    wfe.query();
    while (wfe.next())
    {
        wfe.deleteRecord();
    }
}

View solution in original post

8 REPLIES 8

I reviewed that post earlier and didn't see the UI Action comment all the way at the bottom! I will look into it, but I'm not sure everyone will be comfortable with changing the allowed security role like he has written. I'm hoping there's another way.

sachin_namjoshi
Kilo Patron
Kilo Patron

Just add "if" block after the timer, and if the answer is still "No", disregard pending approval.Otherwise, mark item as approved.

 

Regards,

Sachin

My drawing is wrong (I quickly recreated it from our system in a dev system) but that's exactly what we already have in the workflow to handle closing the approval task. We're looking to cancel the timer itself, so something that runs after the timer won't work.