Rules : access attributes inside mendix tables inside app UI and use it to create business rules

Hi everyone, Is it possible to access the attributes of your entities inside the UI of your app and use the atributes to create business rules. Similar to viewing them in Model reflexion module . example: attribute : DateExpired (datetime) Table: Customer Now I want the user to create rules inside the application and use the attribute ''DateExpired ''  to fire off the rule. So for example send sms 10 days prior to DateExpired value. So I would then retrieve the objects where "Datexpired" value will expire in 10 days time.  Hope im makming sense.   Regards   Slade  
2 answers

Yes, this is possible. As far as I know, it does not already exist, but it sounds like you're on the right track. The reflection module lets you view entities (MxObjectType) as well as attributes (MxObjectMember). So, here's how I'd approach this:


  • Import MxModelReflection into your project
  • Create a new module
  • Add an entity called BusinessRule
  • Add an association to MxObjectType and MxObjectMember
  • Add attributes to define your business rule -- frequency, search type (greater than, less than, equal, etc), action, action message...
  • Create a page view and create BusinessRules - be sure to include reference selectors for MxObjectType and Member
  • Create a microflow that runs every X minutes/hours/days, that reads in all of the BusinessRules and performs the action specified.
  • You may need to use some Java to build and execute XPath based on the rule's related MxObjectType and Member  (see here for a short tutorial on building an XPath query with Java)


Good luck!


Hi Slade,

  Building something like this would be possible, but you would need to get creative with your modeling.  Given the complexity of this solution, it might be simpler to just train users to be Mendix developers and add these rules in the Model at design time instead of run time.  In my experience, the rules don't change so often that they can't be handled in the modeler, where these sorts of changes are simple.  If you have your heart set on a UI interface, however, you could leverage the Model Reflection module for this. 

 -Create a new entity called 'Rule' and add an enumaration for 'RuleType' (Date, numerical), and another enumeration for 'Condition' (greaterThan,LessThan,Equals), and another for EventType(SendAnEmail...other type of event.

-Make an association between MxObjectMember and your 'Rule' entity, and make a page where an admin can select which Attributes from MxModelReflection should be allowed to have rules associated.

-Create an interface where a user can pick from Attributes, create a new Rule, and set the Rule Conditions.  They could do things like if attribute X became greater than value Y then send an e-mail or if

-Make a scheduled event that would run each night to check your conditions and run microflows based on the conditions.  For example, each night you retrieve all the 'Application' entities and then run your rules against them.  Checking to see if the 'due date' has expired and if so send an e-mail to the owner of the applicaiton. 

So the short answer is there is not an easy way to expose a business engine rule to the front end.  Something could be constructed, but I could imagine this spiraling in complexity into something massive.  There would be tradeoffs between what you would do in the Modeler and what you could expose in the front end.  Perhaps it would be better to push for Mendix training and let users create business rules in the Modeler, and simply establish a regular cadence of testing and code pushes so that changes to the model would be moved into production and activated.  I hope you are able to build a satisfying solution for your users!