Validating a Reference selector on a form

3
I have created a Microflow to validate the data entry on a object which contains both a boolean attribute and an association to another object. The association is entered via a reference selector on the data view form, and the boolean is via a check box on the same form. The validation is that if the boolean attribute is false then there must be an association selected but if the boolean attribute is true then there must not be an assiciation. I have set up the validation Microflow as a 'before commit' event on the meta object, but it could alternatively be triggered by a custom 'save' button on the data entry form. Can this be done? If so, how? Thanks.
asked
5 answers
3

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:

  • Variable: select the object containing the reference.
  • Member: select the association which shouldn't be empty.
  • Template: write the validation message. Use {index} to refer to the parameters in the next property.
  • Parameters: a list of parameters each defined with a microflow expression (can be used to define dynamic validation messages).

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.

answered
1

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?

answered
0

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.

answered
0

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?

answered
0

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.

answered