How to cancel a workflow timer?

morrix3
Giga Expert

Hey guys:

I am looking for a way to stop a workflow timer. It is messing with a join activity.  The timer waits 24 hours to auto approve a request IF the approver doesn't do it within 24 hours.  If the approver approves the request before the 24 hours I need a script or a way that will go and stop this timer from continue running.

find_real_file.png

 

11 REPLIES 11

Jace Benson
Mega Sage

Looks like this post has a solution;

https://community.servicenow.com/community?id=community_question&sys_id=9160eed3db70af841cd8a345ca96...

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();
    }
}

I tried this script but i cannot make it work.  What should i change from this script?

This assumes you have a workflow running against the item and that the catalog item is a variable called current.  Have you verified those things?  if you add breakpoints or logs does the code give you values you expect and then stop?  if so where does it stop?

Hey @Jace Benson I am not able delete Executing activity from wf_executing it gives ''

Delete operation against 'wf_executing' has been refused due to the table's cross-scope access policy