How to detect before commit validation microflow returning false

Please consider the following example: I have an entity Product that has a before commit event handler that takes care of some complex validations. It returns false when 1 or more attributes are considered invalid, sending 1 or more corresponding validation feedback messages. Now, I have a new/edit form with a custom 'save' microflow button that performs some extra logic after committing the Product. Now the problem: When the before commit validation microflow returns false, and the Product is not committed, my extra logic after the change (+ commit) activity in the custom 'save' microflow is still executed. I don't seem to have a way to find out if the commit succeeded or not. Defining a error handler on the change activity doesn't work either. How can I detect if a commit fails in a change activity of a microflow? UPDATE: Completely rephrased question... Kind regards, Jonathan
2 answers

As far as we know, this was always the behavior. A before commit handler returning false only affects the actual commit (which won't go through) but does not affect whether the rest of a microflow that has a commit action will be executed.

Are you absolutely sure this was not the case in a previous version? If so, a test project would be appreciated. But either way, the behavior should be as you described for 2.5.5

Edit: There's no way to check if a commit succeeded in a microflow. You could call the validation microflow yourself before committing and then commit without events. Or file a feature request for the commit action to return a boolean which will tell you if it succeeded or not.


This is indeed quite annoying behavior and very tricky. The same problems arise when using datavalidations and the MF is called from a webservice etc. So I use the following rule of thumb/ workaround:

Before commits should always return true or throw an exception

You can throw exceptions by using the community commons package.

Note that one check you can consider is the isNew check if your object is still isNew after the commit, the commit failed. But this is only useful with new objects.