How is the relationship between the two entities set up? That should help us figure out the best way to go about it.
Some possibilities, based on my initial thoughts, are:
- Loop over Entity A. Retrieve all instances of Entity B. Loop over Entity B (still within the initial loop) and then do the calculation.
- Loop over Entity A. Retrieve the instance of Entity B associated with it. Perform the calculation (works only for 1-1 relations).
I'm assuming the BestelOrder somehow has info about which Artikel is related? Either through association or setting some kind of value. I would recommend an association though.
Loop over BestelOrder, retrieve the Artikel that belongs to that BestelOrder and multiply the values. When looping over a list, the object on the list that's used is available as variable $Iterator{objectname}, so that should help.
The solution from Sytze is the most common one and will work perfectly.
But I suspect that you already have a list (in memory) of artikel that you want to use to limit the database reads.
In that case, you can use the list-operation “Find” to get the artikel and calculate the total amount.