Commiting objects with validation rules in microflows

0
Hi all i am having some trouble with creating a nice way to catch validation failures in a microflow. What i am trying to do is commit an Object A in a microflow but i want to be sure that the validation does not fail before i can continue. However, what i do not want to do is use all my BCO microflows and additional ones for the standard validation rules to check if the commit will actually succeed. I already tried to do a commit and then instantly retrieve the same object from the database but this won't work. After searching the forums i also found a solution that involved creating errors so i could use custom error handling for this. But i would prefer to not use any illegal actions or submit my own errors using java. Does anyone have a nice idea on how i could solve this?
asked
2 answers
2

I don't know what exactly you want to do in your microflow, but in general you'd place actions that should only trigger on a successful commit (i.e. no validation errors) as an after commit event on the entity.

answered
1

I usually use custom exceptions (from 'community commons > misc > ThrowException'), since imho that is the most reliable way to make sure that you know that an object is not committed.

But you could also check if isNew($object) is true after the commit, which also indicates indirectly that the commit failed, or, if 'new' is not applicable in your case, check if object has changed since the last commit using community commons > ORM > objectHasChanged. The same behavior as in 'isNew' holds here.

I recommend however using exceptions, the hasChanges/ isNew approach is a bit of a work around, and more sensitive to future API changes.

If I remember correctly, the exceptions are visible in the log, even if you handle them, so thats a bit annoying.

answered