cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Geezer
Advocate I
Advocate I

LoopIndex problem

It appears that tampering with a LoopIndex variable inside the Loop loses its scope when the loop iterates.  Is there a workaround for this?

 

I have a loop that increments by 2, which is used as an index to read from a List.  However, the data populating that list sometimes starts at List[2] and sometimes at List[3].  Each datum contains a data type on one line, followed by a data value on the next. In a Switch statement, the Default case, seeing no valid data type Case was found, decreases the Index by one and the Loop continues, this time in sync with the data.

 

However, upon hitting the Loop statement, the Index is incremented (by 2) from it's original value, and the (successful) Index decrement is tossed  out the window.

 

If this is an error in my PAD Flow, can someone please explain.

 

EDIT: I did find a workaround by modifying my process. But this issue still bothers me for future coding efforts.

1 ACCEPTED SOLUTION

Accepted Solutions

I have edited the flow to use a workaround at this point, so I no longer have info to show.  Basically, though, it looked something like this:

 

Loop (i=2 to 8; increment by 2) {

   IF (condition is met) {  // data list has an extra line

       decrement i by 1;

       }

  switch (i) {

    . . . 

  }

  END Loop

 

 

During a single iteration of the loop, if the index was decremented, it remained that value for the duration of that cycle.  However, once the loop iterated back to the top, the decremented value of the index was discarded and the loop continued as if the decrement never occurred.

View solution in original post

6 REPLIES 6
v-bofeng-msft
Community Support
Community Support

Hi @Geezer :

Could you please show me your flow and the expression?

Best Regards,

Bof

I have edited the flow to use a workaround at this point, so I no longer have info to show.  Basically, though, it looked something like this:

 

Loop (i=2 to 8; increment by 2) {

   IF (condition is met) {  // data list has an extra line

       decrement i by 1;

       }

  switch (i) {

    . . . 

  }

  END Loop

 

 

During a single iteration of the loop, if the index was decremented, it remained that value for the duration of that cycle.  However, once the loop iterated back to the top, the decremented value of the index was discarded and the loop continued as if the decrement never occurred.

View solution in original post

Hi @Geezer :

It seems that it may be possible to define a variable of type number and then use do until action to implement the loop. I noticed that you mentioned that you already have a workaround,do you still need any help now? What can I do for you?

Best Regards,

Bof

Yes, I have a workaround for this time.  I don't personally need anything, I was just reporting the issue and hope the flaw in functionality will be addressed soon. The next time I need a FOR loop, I would like it to work the way it used to.

Hi @Geezer :

Thanks for you feedback.

BTW,If you have any suggestions for Power Automate, you could also consider posting your ideas to this forum:

https://powerusers.microsoft.com/t5/Power-Automate-Ideas/idb-p/MPAIdeas 

Best Regards,

Bof

Thank you for the help. I am currently going crazy trying to figure out the GUID construct in PA. Separate thread....

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,437)