181
Views
9
Comments
ForEach cause Infinite Loop
Application Type
Traditional Web
Service Studio Version
11.10.8 (Build 37885)

Hi All

Sorry, I can't share my real module and the attached action flow does not reproduce my issue.

But they have the same flow.

Even the SourceList only has one element it never ends the loop. My thought is that ListAppendAll copies the list, But it somehow points to the same list, and the ListFilter cause CurrentRowNumber reset.

Any suggestion is welcome. 

Kind Regards,

2021-01-19 14-07-32
Tom Zhao

Addition information.
1, I tried to replace ListAppendAll with ListDuplicate, But no luck.

2, If I delete the if node ("SourceList.Current.Name = ListFilter.FilteredList.Current.Name" ), then the loop is only run one time. Sorry, the node information of my first image is wrong. It uses a filtered list value.

2020-08-31 10-11-32
Ragavi Arumugam

Could u explain what are you filtering out with ListFilter?

2021-01-12 13-21-28
Kadu Borges

I have tried to duplicate the scenario, but it always ends. I have two questions:

  1. The first one is the same as Ragavi: what are you filtering and in what list  are you doing this?
  2. What is the relation between SourceList and GetClasses3? Are they related to the same Entity?
2021-01-19 14-07-32
Tom Zhao

Hi 

Thanks for every reply. The Image attached is not my real module that got the problem, but the logic is similar.

My problem is even first ForEach's source only has one element, and when it cycles back to the ForEach node the CurrentRowNumber is 0. 

Kind Regards,

2021-11-19 11-12-44
Rui Mendes
Due to the way the flow in the cycle arm is implemented, it ends the first time the list filter has no results or the name is different.

I think that what you really want is to add one more entry to the output variable, always in not empty and the name exists.
2024-10-25 09-14-42
Christopher Bautista

Hi Tom,

Good evening!

What is the filter condition of your aggregate? I think the issue is on the 2nd loop. Amd as Ragavi mentioned, what is the condition of your Listfilter.

Kind regards,

Chris

2021-01-19 14-07-32
Tom Zhao

Hi 

Thanks for every reply. 

My problem is even first ForEach's source only has one element, and when it cycles back to the ForEach node the CurrentRowNumber is 0. 

I finally changed ForEach to If loop and judged by local available that indicate the current index, the problem is solved. I just curious why this happens.

Kind Regards,

2017-12-15 03-31-24
Lennie Sutton

Tom,

      I've been using Outsystems for years now and for the first time I'm running into a similar issue as you describe above.  I have nested loop (header and detail records) I'm trying to process, but when it goes back to the outermost loop after successfully processing the detail records, it appears the CurrentRowNumber stays at zero so putting a max on the iterations doesn't stop it either and it keeps inserting the same record with each iteration until it crashes.  I tried changing the aggregate to a list, but the same behavior persists.  I haven't figured out yet why the loop is not advancing to the next record, but will continue to track this down.


For now I've put in a counter that I manually increment and exit when it reaches my max iterations, but this does not solve the issue with the for each loop not advancing.

Service Studio: Version 11.54.49 / Build 63182
Platform: Version 11.24.0 (Build 41209) 
React project

Best Regards,

2017-12-15 03-31-24
Lennie Sutton

Strangely....disabling the application and re-enabling it seems to have made it behave again, but I think I'll leave my other checks and exception handling in just in case it decides to not advance again.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.