How to cancel a workflow timer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 08:43 AM
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.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 08:58 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 09:24 AM
This needs to happen automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 09:50 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 10:39 AM
Hi:
I don't want to cancel the entire WF only the timer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 10:59 AM
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;
}