You are viewing limited content. For full access, please sign in.

Question

Question

How to Terminate Parent Workflow When Invoked Workflow Terminates?

asked on March 25

I have a workflow (parent) that invokes another workflow (child). The parent workflow is set to wait for the invoked workflow to complete before continuing. When testing an instance, the child workflow terminated and the parent workflow continued and didn't terminate. Is there a way to have the parent workflow terminate when a child workflow terminates?

I know that there are 3 tokens available from the invoke (Invoked Workflow Completed, Invoked Workflow Duration, and Invoked Workflow Termination Reason), but I can't find any definitions as to what to expect from these tokens. I am guessing the best way to approach this is to use a Conditional Sequence or Decision activity and use one of the 3 tokens above, but I wanted to see if there was an easier way to terminate the parent workflow. If not, are there definitions somewhere as to what the 3 tokens the invoked workflow produce are?

Workflow v12.0.2510.3321

0 0

Replies

replied on March 25 • Show version history

For clarification, in the child workflow I am not using an End Workflow activity. I am trying to catch when a child workflow terminates for unexpected reasons, like if it has issues sending an email or contacting a SQL server to perform a query.

0 0
replied on March 25 • Show version history

The way I usually handle this is with output parameters. For example, I might create a Success or HasError type token with a default value, put everything in a try-catch, then update the output in a Catch block.

Then, I add a condition after the child workflow that checks the output and ends the workflow it the child failed. I never really utilized the default "termination reason" token since I usually need to catch errors.

0 0
replied on March 25

This is the way. Use a Try Catch to customize the behavior and once you catch the error, use End Workflow in the Catch branch to tell the parent how to terminate. 

1 0
replied on March 25

I'm hoping I don't need to add try-catch activities throughout my workflows since some them have several activities where they would be needed. If one of the 3 tokens that I mentioned passes a value when the child workflow terminates, it would be a lot easier.

0 0
replied on March 25

If there isn't a way to use any of the 3 tokens, is there a list of activities that are recommended to wrap in a try-catch?

0 0
replied on March 25 • Show version history

I did some testing and noticed a couple of things. If the child workflow terminates, the Invoked Workflow Completed token comes back as False. If it finishes successfully, that token is True.

The Invoked Workflow Termination token is only populated when the child workflow actually terminates; if everything runs successfully, it stays empty.

For my use case, I’m planning to just check the Invoked Workflow Completed token and see whether it’s True or False. If it’s False, I’ll use an End Workflow activity to terminate the parent workflow.

This seems like it could be a much simpler approach and avoid needing extra activities like Try/Catch branches and multiple End Workflow steps. If anyone knows of any downsides or edge cases with doing it this way, I’d love to hear about them.

5 0
You are not allowed to follow up in this post.

Sign in to reply to this post.