calculating an attribute by multiplying 2 attributes

1
so, i have got OrderLine, which has the attributes TotalPrice, amount and Price. I want totalPrice to be calculated automatic, by multiplying price by the amount. I suppose you need a microflow to do this, but how do i do that? thanks in advance
asked
2 answers
2

Easy enough:

https://modelshare.mendix.com/models/f5f72af1-3b1c-493e-a95f-e69e8f73daa3/calculate-total

Just assign the microflow to the calculated attribute and multiply the 2 attributes in the end event.

answered
0

One note: calculated attributes have a negative impact on performance in entities with a large number of objects. You may want to consider populating your total price field with an on change microflow on your price and amount input fields or as an event handler on your entity, whichever is more appropriate for your app. It seems like OrderLine entity may have a lot of objects in it at some point in your app lifecycle. If so, each time you retrieve a list of OrderLine objects, the total price will be recalculated for each object when using a calculated attribute.

answered