Iterate over a List and save each iterationstep as Attribute
Hello Community, i’ve got two entities. The first entity is the Number of an Object (e.g. Order Number) und the second entity includes all Parameters as Attributes (e.g Price of Product, Running Number of the Product in the Order), to describe the Object. These two are associated (1 Number – many Parameters). In the List view the example looks like this: Ordernumber running number product price pricesum 1234 1 xyz 1€ 1€ 1234 2 rst 4 € 5€ In the current microflow i retrieve a List of the Parameters by the association, sort them by an attribute (e.g. running number) and then there is the problem. I want to iterate over the sorted list and add an attribute (e.g. price). The sum for each iteration step should be stored as Attribute (e.g. pricesum). In the example: the Price after each Product in the same order (after step 1 = 1...after step 2=5 and so on). As expression it would look like this: Price(n-1)+Price(n)=PriceSum If I use a loop the Attribute “PriceSum” is the Sum of the whole List. I hope someone can give me an approach to a solution. Thank you in advance! Jan
So you say: SumPrice(n) = price(n-1) + price(n). I will assume that price(-1) = 0, and I have initialized the variable SumPrice to that value.
The first action in the loop calculates SumPrice(n): SumPrice at that point in time holds price(n-1) and you add price(n).
You can then do something with SumPrice(n). I simply assign it to OrderLine/SumPrice attribute, but you could call a microflow with this as input parameter etc.
Finally, I set SumPrice to price(n), so that it is prepared for the next iteration of the loop: in the next iteration, I start by adding price(n) to this value, which, in that iteration, is price(n-1).
Rom van Arendonk
I rebuild your Microflow, but in mine something went wrong.
This is my Microflow, do you know where i have to commit Activities in the Loop and where not ?
With the Button I call the Microflow in this case all values are the same. And thats not the favored behavior. Maybe you can detect my fault with the snapshot.