Unable to pass variable into For Each Max Iterations

Hello. I have a weird issue which I couldn’t help solve. Not even ChatGPT could help. I have a variable called BreakInterval of type Int32. I have assigned it a value of 1 for now for testing purposes. I have a For Each activity with type argument as String. In the Max Iterations field, I have set it to BreakInterval instead of manually typing in 1. The Assign activity is placed right above the For Each.

Results:
Manually typing: Only iterates a single time.
Using variable: Iterates infinitely without stopping.

Note: I have latest packages installed UIAutomation.Activities 23.10.3 and System.Activities 23.10.2. I even downgraded to previous version to see if its related to the packages and even restarted Studio, both had no effect. Any suggestions?

Make sure you only have BreakInterval created once (you can check by searching for it in universal search and seeing if it shows up twice with the ‘v’ icon). If you accidentally create a variable more than once in different scopes, you can get unexpected results like this.

remove duplicate variables (check if theres a yellow exclamation mark next to the variable)
image

if there are none and its still not working you can do this instead
create an index variable and use it in the index property in for each loop, inside the loop have an if statement with the condition index >= BreakInterval

Did what you mentioned, no errors or exaclamation warnings show. I’ve hit Ctrl F to find all the instances where this variable is located. It is present in three places.

  1. In the variables panel.
  2. In the multiple assign activity at the very top.
  3. In the Max Iterations property field of the For Each loop.

I tried this out on Studio 2023.10.0 and was able to reproduce it with various versions of UiPath.System.Activities → To me it seems indeed like a bug.

1 Like

try to set the variable scope higher as the for each level

I already told you in the previous post that I did what you mentioned. It did not work. Pretty sure its not a duplicate issue. Is it possible to be a bug? I usually solve 99.9% of all problems, but this, its just simply weird.

Already did, had no effect.

Thanks @efelantti for confirming that. Indeed it’s possible to be a bug.

we saw buggy behaviour as also working behaviour. Difference was

  • UiPath.System.Activities Version Level
  • Project Compatibility

For further analysis we traced the variable with debugging and debugging panels
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Simple demo I did.

It should stop after mouse, but it iterates through all of them.

Ye, it’s bugged with variables atm.
I can confirm I get the same result as you, but it works with hard coded values.

Here is my test. with version, 2023.10,

image

True. So how do we report this to UiPath dev team? I obviously need this to work.

I’m not sure. Perhaps the feedback section?

I saw there was some activity from a UiPath guy on the Release Recap post.
So perhaps a comment on that post yields the best result.

I would personally implement a workaround if you’re on some deadline. :grimacing:

Here is a 23.10 patch notes thread where a dev was active 2 hours ago:

I wish they had a megapost for bugs.

I tagged loginerror for this. Hopefully he can assist on this. Thanks anyways.

Thank you for the above discussion and @private_matter for pointing it out to me.

We’ll fix this bug in the next version.

3 Likes

Just want to confirm that the upcoming System 23.12 package will fix this issue.

@loginerror Thx for letting me know!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.