How to check in a microflow if commit was succesful.

2
I'm using a microflow coupled to a custom 'Save button' on a Customer form. So it has a "Change object with commit" action somewhere. That commit may fail on a 'before commit' check. If the commit succeeded I want to send a mail to the customer (say 'Welcome' or 'Your data are changed'. If the commit didn't succeed, of course, the mail should not be sent. But the 'change object' action doesn't have an output (for example, a boolean to show success or failure). My question: how to check if the commit was succesful. The only thing I can think of is to reread the record from the database and check the 'last modified' timestamp. If that's less than, say, 5 seconds ago (or if there's no record for a new customer), it can be considered as a failure, otherwise it's a success. But that's rather clumsy. Is there a better way? Kees
asked
3 answers
3

How about creating an "after commit" action? I haven't tried this myself, but I think it only fires if the object was committed correctly.

answered
3

If a microflow reaches the activity defined after the commit activity the commit was successful. If a commit is not successful the commit activity will throw an error and the microflow does not proceed it's execution (if error handling isn't set to continue).

So, you can just add the mail activity directly after the commit activity.

answered
1

The only way I see is that you execute whatever before commit checks you do in the microflow itself (not as an object handler) This way you can check whether it returned true or false and handle the two outcomes in whatever way you want.

I think in general, when using custom made 'save' and 'cancel' buttons, object handlers are not always the best way to go, certainly not for checks (you could still use them to set e.g. complete names based or calculate total order values).

I use custom save and cancel buttons all the time and we are working with a 'validation' subflow in every custom save microflow so that we can choose per save action which checks should be executed and which not

answered