Problem fixed: for each loops run concurrently, so it was running everything at once. Setting the concurrency to allow only 1 run fixed it.
Append one entry to empty array variable is adding several entries
I have a list of entries from an Excel sheet. I group them by a code and then for each code I need to create an array of entries for each of the entries with that code.
I initialise an array and start the for each
In the for each, I filter by code. This step successfully results in an array of 3 entries with the same code X from an array with 20+ entries with different code. The next for each runs 3 times (as expected).
Inside the inner for each (which runs 3 times), I compose a text for each entry and add it to an array variable.
Once outside of the inner for each, I compose a text with the result and reset the array.
The expected result would be a text showing the array with 3 entries, all with the same code X, but when I run this I can see that the array contains several entries and with codes other than X.
Adding some "debugging" compose, I can see that the array is empty when the inner for each (For each entry per code) starts (Compose 5), but when "Append to array variable" happens, another "debugging" compose (Compose 2) shows that the array has already random entries with random codes, even if the Compose above it is only producing a single entry (notice the scrollbar, indicating many more entries than the expected single one)
What am I doing wrong ? I reset the array variable before entering the outer for each and at the end of the outer for each, the "debugging" compose shows that the array is indeed empty at the beginning of each iteration, so where is this extra data coming from ??
Azure Logic Apps
2 answers
Sort by: Most helpful
-
-
MayankBargali-MSFT 70,936 Reputation points Moderator
2024-04-08T06:01:42.44+00:00 @Francesco Ghigo I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution in case you'd like to "Accept" the answer.
Issue:
You observed that your array variable was not having the expected value inside the for each action
Solution:
You found that for each loops run concurrently, so it was running everything at once. Setting the concurrency to allow only 1 run fixed the issue. For more details, please refer to this document.
Thank you again for your time and patience throughout this issue.