cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

How to act on cancelled workflow

Jump to solution

If a workflow is canceled or has errored out, I need to update the list item to reflect a different status. (We have our own internal status for the process) How can I determine if the workflow was canceled or errored out and update the list item prior to the workflow finishing? 

0 Kudos
Reply
5 Replies
Workflow Hero

Re: How to act on cancelled workflow

Jump to solution

I'm afraid you won't be able to cache canceled workflows, but for errors ... you could catch errors within your workflow (where possible) and then for e.g. use either a UDA or a state to set some additional values and then terminate the workflow (so it's actually ended instead of leaving the workflow in error-status). Maybe the handling of errors and terminating the workflow will obsolete the need to cancle workflows.

Reply
Workflow Hero

Re: How to act on cancelled workflow

Jump to solution

You could have a "clean up" workflow after the fact that queries for items where the workflow status is "Cancelled" or "Error Occurred", and then updates the field for those item.  You could make it a site workflow and schedule it to run at a regular interval.  The one thing you have to remember is that even though you see text for the status, that actual status is a number.  So you have to query for the number.  So for Error Occurred, and Canceled, the numbers are as follows:

  • Error Occurred = 3
  • Canceled = 4
Reply
Workflow Hero

Re: How to act on cancelled workflow

Jump to solution

So this brought up another question - related.  If a workflow errors, I can capture that error and set a status of "Error" or something similar.  In my present scenario, I have one workflow that calls another workflow.  The calling workflow waits until the called workflow finished.  Is there a way to check the status of the called workflow after if completes?  I am thinking that if I can tell if the called workflow had an error, then I can act on that.

Reply
Workflow Hero

Re: How to act on cancelled workflow

Jump to solution

If a workflow "Errors", the status is automatically set to "Error Occurred", and the workflow ends.  There is nothing you can act on in that scenario.  Now if you're calling a workflow from a workflow, then after the called workflow finished, you can query the status of that workflow like I mentioned above.  However I'm not sure if the main workflow would continue if the called workflow Error's out.  Haven't had that scenario before, so you would need to test it out.  

Reply
Workflow Hero

Re: How to act on cancelled workflow

Jump to solution

So my actual scenario had one workflow kicking off another workflow which then kicked off another workflow.  That last workflow wrote to a SQL database.  Sometimes we would get a SQL error which wasn't properly handled in the workflow.  I ended up adding an action that would check to see if there was an error in my "Write to SQL" action.  If so, I would set the status to "Error Writing to SQL" and exit.  I then modified the workflow that called it to check the status of the workflow it called and if it was in an error status, to set itself in an error status for the first workflow.

This is rather complicated but the company that was here before me deduced that in order to get the timing correct, the process had to be three workflows dependent on each other.  

If there is a better way - I'd love to hear it.  Right now, I believe I have all workflow exiting cleanly and based on the error condition, I can act on them.

0 Kudos
Reply