324
Views
18
Comments
Solved
List was redefined while being iterated
Question
Application Type
Reactive

I am trying to refresh an aggregate so that the 'Add Subject' button would be disabled if the refreshed aggregate has the subject chosen in the dropdown. However, I got the 'List was redefined while being iterated' error.

I am very new to Outsystems so I hope someone can help me understand why this is happening and how I can fix it.

UserImage.jpg
Puja Rani
Solution

Hi,

Error is occurring because you are trying to refresh the same list which is in for loop. While the list is being iterated you can't define/change the source. Instead of refresh, you can use a list filter action and add your condition(i.e. to check subject chosen in the dropdown ), and use the output of list filter to enable/disable the button. Hope this clarifies.

2023-06-25 14-07-11
ikhwanizao

Hi,

I am starting to understand what you are saying but just one more thing. By list filter action, do you mean filtering the aggregate using server action?

UserImage.jpg
Puja Rani

No, on client side also we have list filter action. Go to Manage Dependencies> System, you can find there, and just drag it to your loop.

2023-07-17 04-42-12
Karthick Balaji
Solution
2023-05-08 05-34-05
Piyali Saha
Solution

As per my understanding of your scenario, I have created a simple demo where I have used list filter to check the selected subject and disable the button if already exists. Kindly refer and let me know if the problem is resolved..

listIterate.oml
2023-01-26 16-03-24
Ana Agostinho
Solution

Hello Izao, 


Basically, what Puja is trying to indicate to you is that OS provides some System actions that allow you to manipulate Lists. In this case, she is recommending you Use the ListFilter one. In Reactive, you can use these actions in the Client or Server side :) 


Here is the documentation link here you can find more information about this:

Best regards, 

Ana

2023-06-25 14-07-11
ikhwanizao
Solution

Thank you, everyone, for your help. However, I have managed to solve this problem by assigning 'False' boolean to the save button variable after clicking on the save button.

2023-07-17 04-42-12
Karthick Balaji

i hope now you are get the result as you expected 


regards

karthick

2024-09-27 19-05-42
Ravi Kumar Tasubilli

I told you before your issue will be resolve by using the boolean variable. anyway you got the solution.

UserImage.jpg
Puja Rani
Solution

Hi,

Error is occurring because you are trying to refresh the same list which is in for loop. While the list is being iterated you can't define/change the source. Instead of refresh, you can use a list filter action and add your condition(i.e. to check subject chosen in the dropdown ), and use the output of list filter to enable/disable the button. Hope this clarifies.

2023-06-25 14-07-11
ikhwanizao

Hi,

I am starting to understand what you are saying but just one more thing. By list filter action, do you mean filtering the aggregate using server action?

UserImage.jpg
Puja Rani

No, on client side also we have list filter action. Go to Manage Dependencies> System, you can find there, and just drag it to your loop.

2023-01-26 16-03-24
Ana Agostinho
Solution

Hello Izao, 


Basically, what Puja is trying to indicate to you is that OS provides some System actions that allow you to manipulate Lists. In this case, she is recommending you Use the ListFilter one. In Reactive, you can use these actions in the Client or Server side :) 


Here is the documentation link here you can find more information about this:

Best regards, 

Ana

2023-05-08 05-34-05
Piyali Saha

Hello Izao, 

You need to use list filter action from system module through manage dependency to filter the list rather than refreshing the same aggregate which in output throwing the error of list was redefined while being iterated.

If you need more explanation on how to do the same, kindly let me know then I will definitely help you out will the demo oml of the same.

Thank & regards.

2023-06-25 14-07-11
ikhwanizao

Hi Piyali,

Would you please show me or explain how to do it? I tried it but it gave me another error saying "list is being iterated filter is not allowed". Thank you in advance.

2023-05-08 05-34-05
Piyali Saha
Solution

As per my understanding of your scenario, I have created a simple demo where I have used list filter to check the selected subject and disable the button if already exists. Kindly refer and let me know if the problem is resolved..

listIterate.oml
2024-09-27 19-05-42
Ravi Kumar Tasubilli


Hi Izao

You are refreshing the same list which is used for the forloop. when for loop iterating again you refreshing the same list that's why you getting error.

and why you need to refresh the aggregate if you want to disable the button use the Boolean variable and assign value.

Thanks,

Ravi Kumar

 

2023-07-17 04-42-12
Karthick Balaji

@Izao  still you are iterating the list again and again its looping so only you are getting the error if you don't mine can you share your OML we can get much clarity while looking into your code 



thanks and regards





2023-06-25 14-07-11
ikhwanizao

Hi, sure. Thank you in advance.

UniversitySystem_Core.oml
UniversitySystem.oml
2023-07-17 04-42-12
Karthick Balaji

now tell what are you trying to do where in this OML file 

2023-07-17 04-42-12
Karthick Balaji
Solution
UniversitySystem.oml
2023-06-25 14-07-11
ikhwanizao

In OnSubjectChoose Client Action in LecturerSubjectAssign, I am trying to refresh the aggregate so that after the subject is added, the 'Add Subject' button would be disabled right away. As of now, it will only be disabled if I select another subject, then reselecting the added subject again. Otherwise, it would not be disabled, making it possible to add the subject more than once which should not happen.

2023-06-25 14-07-11
ikhwanizao
2023-07-17 04-42-12
Karthick Balaji

first check that one and tell me what will happens



thanks

2023-06-25 14-07-11
ikhwanizao
Solution

Thank you, everyone, for your help. However, I have managed to solve this problem by assigning 'False' boolean to the save button variable after clicking on the save button.

2023-07-17 04-42-12
Karthick Balaji

i hope now you are get the result as you expected 


regards

karthick

2024-09-27 19-05-42
Ravi Kumar Tasubilli

I told you before your issue will be resolve by using the boolean variable. anyway you got the solution.

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