Getting the value of an associated entitys attribute

0
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.
asked
2 answers
6

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

 

Example: https://modelshare.mendix.com/models/ee345978-0691-4683-8b58-9289eb7d2bbe/order-line-set-price

answered
0

That did the trick. Thank you very much.

answered