2 Entities in a Loop

0
Hey all, With my microflow I need 2 atributes from 2 different entities in a loop. From entity artikel I need the buy price of the artikel and from the entity ‘Bestelorder’ I need the amount of the artikel that is ordered. In a loop I need those to be multiplied with each other to get the total amount of it being ordered. However I cant get the 2 entities in the same loop. Any help?
asked
3 answers
2

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).

 

answered
1

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.

answered
0

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.

answered