Getting the value of an associated entitys attribute
Hello everyone, I am new to Mendix and I am trying to develop a very simple project. This is my domain model: The value of the amount attribute should be unitPrice * Quantity. The thing is that the OrderLine unitPrice should be the Product unitPrice and I can't find a way to get it from the Product and assign that value to the OrderLine unitPrice. I tried to use a microflow with a Change Object action which would multiply the OrderLine quantity by the Product unitPrice, but there's no way I can access the Product unitPrice through the OrderLine ( which is a parameter of the microflow). Any ideas? Thank you in advance.
You need to retrieve the Product via the association with OrderLine_Product in order to access any of it's attributes. This can be done using the "Retrieve" action and then "Retrieve via association", assuming the association between Product and OrderLine is already set.
Once you have the Product object in your microflow you can set the $OrderLine/Amount with a Change Object on the OrderLine and then set $Product/unitPrice*$OrderLine/quantity