Workflow restart or reset on task cancel

ericgilmore
Tera Guru

I have a workflow with several Catalog Tasks. These Tasks transition to a Join when they are complete. The Join transitions to a Wait for condition and then an end.

I was wondering, if there is a was to handle situations where someone closes all the tasks initially, but then goes back and sets a task state back to something other than Closed {complete, incomplete, skipped}. (I guess b/c closing was a mistake?)

What I've seen happen, is that the Request Item is set to Closed complete, Inactive, and it doesn't automatically start the workflow from that point again.

Would checking or waiting to check if all tasks are really closed before passing to a Wait for condition and End be an option? It's sort of like a redundant check, that pauses before the final check, in case someone made a mistake and closed all the associated tasks. I think. Or some type of workflow that's tolerant of a "Cancel" state?

Anyone done anything like this?

1 ACCEPTED SOLUTION

Manish Vinayak1
Tera Guru

Well, in this approach, the wait duration is not certain, the task can be cancelled any time after being closed. You could add a fixed wait duration to make your workflow but that won't work if the task gets cancelled after the time has passed.

 

One way to do what you want is having an after update business rule in Catalog Task table for that specific Catalog Item, with a condition to trigger only when the Task state changes from "Closed Complete" to "Cancelled" / "Closed Incomplete". In the business rule, you can have a script to restart the workflow. You can get more information on how to restart a workflow using scripts here:

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_WF-restartWorkflow_GR_B

E.g.

      new WorkflowApprovalUtils().cancelAll(current, comment);
      new Workflow().restartWorkflow(current);

View solution in original post

3 REPLIES 3

Manish Vinayak1
Tera Guru

Just a thought, would it be worth restarting the workflow just if one of the tasks was marked as cancelled after being closed? I mean you wouldn't need all the activities (approvals, other independent catalog tasks, notifications etc.) to be done again if just one task was cancelled.

One approach to handle such situations could be having an after update business rule in Catalog Task table, to mark the requested item as Closed Incomplete if the task was initially closed and then later changed to cancelled.

You can have a notification where the task changes from 'Closed Complete' to 'Cancelled' and the requested item from 'Closed Complete' to 'Closed Incomplete', just so that teams / user are aware that which task was cancelled and then they can take required actions.

 

Well, maybe restarting. But how do you implement something like that? Something that actually pauses and waits for a possible state change before finishing out the workflow?

So something akin to this I'm guessing.find_real_file.png

Just a guess.

Manish Vinayak1
Tera Guru

Well, in this approach, the wait duration is not certain, the task can be cancelled any time after being closed. You could add a fixed wait duration to make your workflow but that won't work if the task gets cancelled after the time has passed.

 

One way to do what you want is having an after update business rule in Catalog Task table for that specific Catalog Item, with a condition to trigger only when the Task state changes from "Closed Complete" to "Cancelled" / "Closed Incomplete". In the business rule, you can have a script to restart the workflow. You can get more information on how to restart a workflow using scripts here:

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_WF-restartWorkflow_GR_B

E.g.

      new WorkflowApprovalUtils().cancelAll(current, comment);
      new Workflow().restartWorkflow(current);