Since 2.4.3 you can use the 'Show validation message' microflow activity to send validation messages to the client.
So, in you microflow you should check if the boolean false. If so you can check if the association is empty. If that's the case you use the 'Show validation message' activity to send a message to the client that the association is required if the checkbox isn't checked.
The 'Show validation message' has the following properties:
If you use this microflow as before commit event you need to return false to prevent the framework from committing. If you return false the form in the client will not close (because the commit failed) and will show your validation below the appropriate input.
Hey Andrew,
I just tried to create a simple testcase. On the default Edit User form I added an action trigger, which calls a microflow with only one action in it to send datavalidation feedback for the Language reference selector.
Here's the call when I click the action trigger (aka custom save button): {"action": "executeaction", "params": {"actionname": "System.Validate", "entity": null, "guids": [281517926383617], "applyto": "selection"}, "context": [281517926383617]}
Here's the response: {"actionResult":"","datavalidation":[{"guid":281517926383617,"errorFields":[{"name":"System.User_Language","message":"Whoa!"}]}]}
The text Whoa! is displayed justt below the Language selector.
When I move the datavalidation feedback action into a before commit action on User, and replace the action in my action-trigger microflow with a commit-action for the User object, same thing happens.
Can you provide more detailed information on your issue?
Hi Johan - thanks for that, but it's not working as I expected. I have created a microflow attached to a 'before commit' event. The microflow comtains simply one validation message (I've removed the check on the boolean for now just to keep it simple for testing) as you describe above. However it is failing the validation if the association empty or if it is filled. Am I missing something? Thanks.
Hi Hans / Johan - My problem is that I get the validation error message displayed both when the validation fails and also when the validation passes. Also, as far as I can see the 'Show validation message' activity doesn't return any value, so all the subsequent actions in the microflow are processed both when the validation fails and when it passes. What I need is a microflow which can first validate either that the reference selector is filled or that it is not filled and then either return to the form without processing any further actions or continue (if the validation passes). Can this be done?
Sure... the 'Show validation message' does not return anything indeed... It just makes happen what the name implies. Probably you just want to first check the condition ($reference = empty) in a split, then do the Show Validation when the result is false, and otherwise... skip the 'Show validation' action!
Anyway... the 'Show validation message' is just a command so send feedback to the client. It's not executing any validation itself.