Assocations in a microflow

I have 2 entities. The objects from the 2 entities should be associated with eachother. The problem I have is that there are business rules for the association. For example: A diner can only be included when a program exists of 15 to 30 customers. I'd like to know how a microflow will either show the options which can be possible or gives an error when an impossible option is saved. I used a reference set selector for the associations between the entities and the association is M to M. I recently started to get to know Mendix. I hope you can help me, thank you.
2 answers


As I don't know your application, lets use the following scenario:

  • I am building an app to enable Customers to purchase insurance Products
  • Customers can have 1 person or more than 1 person (for instance, I may enter myself as a customer and add my child to my customer record)
  • In my app, I want to offer family Products to Customers with more than one person, and single Products to Customers with only one person and no Products to Customers who have not entered any people
  • Customers has a 1 --> M association with Person
  • Customers has a M <--> M association with Products
  • Customers has a boolean attribute that indicates if the customer has multiple people

Now I can create a Customer Product selection page for a Customer. On that page, I can have a DataView for Customer and 2 separate reference selectors: one which retrieves both family and single products and on that retrieves only single products. I can make those reference selectors visible based on the boolean attribute on the Customers entity. In this way, a single customer can only select single products and a family customer can select single and family products.

You could also do this check in a microflow when a product is selected. However, this is not a great approach, IMO. If I know, as the app developer, that a given customer cannot purchase certain products, why show those products in the first place?

There are other ways to accomplish this also, this is just the first one that comes to mind.

Hope that helps,



I agree with Mike's solution as one way to deal with this. Have you tried creating a validation rule on the commit of joining a Program? For example, create Program, but then create specializations of that Program with associations to the Diner, but then the specialized Program should have a validation rule on Commit that the Diner meets the criteria (or the Program meets it's own criteria). That's another way you could look at solving this I think.