Today I encountered the following error message in the failed system jobs.
This was generated by a workflow that will update the active stage of a business process flow record from a custom entity.

This didn’t look familiar to me in any way, so further investigation was needed.
After some digging around in the system, I was able to put all pieces together.

For the purpose of this blog post, I created a very basic BPF and workflow to simulate the issue.

The failing workflow

First thing on the checklist, what happens in the workflow that is causing the failure.

This is the workflow definition

In the actual update step, the active stage is set to Close.

So absolutely nothing fancy or out of the ordinary there… at first sight!

The Business Process Flow

Next on the checklist, the Business Process Flow.

Now, this drew my attention immediately… there are 2 stages with the name ‘Close’.
One for each branch of the condition.
So which one did we set in the workflow? To find out, let’s change the display names of the stages to Close (1) and Close (2)

Back to the Workflow

When I open the update step, I can see that the active stage will always be set to Close (1)

Obviously, this is an issue when my Business Process Flow is in the other branch, where Close (2) is expected as the active stage.
This will be the case when my Event Type does not equal Type 1.
As my main color is blue on the Insight Profile test … I have to be 200% sure, so lets put it to the test.
When I select Type 2 as the Event Type, will I receive this error?

There we have it…

The solution

Extend the workflow with the same conditions as you created in the Business Process Flow and select the matching stage for the branch.

Conclusion

You can only set the active stage to a stage that is defined in your current branch or to a stage prior to the branching.
Figuring out which stage you set in a workflow is a pain in the *** when several stages have the same name. Only option (I found) is renaming them in the BPF configuration, update your workflow, and changes the names back.

In my real-life example today, the BPF consists of several branches and 6 Close stages. So extending the workflow was quite a hassle.
Perhaps any of you out there have a better (or at least more efficient) way of handling this problem?
If you do, we would love the hear about it 😉