MENDIX Adding Validation Rules efficiently using rules
Let say we want to checks on a forms that the content of many fields is not empty
to manage this efficiently we will use A rule and add the validation on our save form button
First we will create a rule
what is a rule?
A rule is a special kind of microflow. Its result should be an enumeration or a Boolean and it can be used in a decision to make a decision based on that result. The idea is that complicated decisions can be consolidated in rules and reused in various places.
Rule Differences from Microflows
Rules are very similar to microflows
There are only a few differences between rules and microflows:
A rule can only be used in a decision
The return type has to be Boolean or enumeration
A rule cannot change data in the database
the actions to create, delete, change and rollback objects are not available in rules
A rule cannot interact with the client
the actions to show or close forms, show messages, send validation feedback and download files are not available in rules
A rule cannot call web services, generate documents or import XML
Lastly on your microflow where you will add your validation add the validation activities with the above created rule
To ensure that the user is made aware of any problem in the form, you can use the Validation Feedback activity. This activity allows you to select an attribute on an entity so that Mendix can figure out where to show the validation message on the input form.
Add validation messages to the false flows of your decisions and set the variable, member, and Template properties accordingly.
After each of the validation messages add a Change variable activity that sets the EmployeeValid variable to false. Finally, add Merge activities just after your Decision activities so that the microflow can continue processing.