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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

If it's just for one record:

- Search for the Workflow context [wf_context table], copy that sys_id
- Search in the Schedule for name *sys_id [sys_trigger table]
- Simply put the Next action date in the past

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

This needs to happen automatically.

Ian Mildon
Tera Guru

You could use one of the following options in whatever "trigger" you want to use to cancel the workflow.

new Workflow().cancel(current); //cancel

new Workflow().deleteWorkflow(current); //delete

Hi:

I don't want to cancel the entire WF only the timer.

morrix3
Giga Expert

Ok so this is what i did to fix this issue.

Since the problem wasn't actually the timer but the join activity that was being thrown off , i replaced it with a wait for condition.

 

answer = true;
var grCatTask = new GlideRecord('sc_task');
grCatTask.addQuery('request_item', current.sys_id);
grCatTask.query();

while(grCatTask.next()){
    
    if(grCatTask.state != 3){   // check if the state of TASK is not closed
        answer = false;
    }