How to allow user to only create a new order when the price of the order does not exceed the customers credit limit?

Hi, I'm using Mendix for a school assignment. I have two entities, Customer and Order. When creating a new customer, you are required to set a credit limit for that customer. The entities are associated with each other, so when you create a new order, you are required to select the customer the order is being made for. Now, I need to make sure that the price of the new order cannot exceed the credit limit that has been set for the customer that has been selected. I have no idea how to do this, but I'm assuming it has something to do with microflows. Help would be much appreciated, as I've been stuck on this part of the assignment for days. Thank you.
2 answers

Hi yes, you should do this with a microflow. You could do it in the following steps, or something similar:

  1. When you have created the new order and have set the customer > create a microflow that will save your order.
  2. With the microflow you will retrieve the customer over association
  3. Then compare the credit limit set with the customer versus the price of the new order
  4. If it exceeds show a validation message to the user, if it does not exceed continue and save

I Think Maarten's answer is perfect! Or do you need help with the Microflow Expressions? Then please share a screenshot of your domain model ;-)