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.
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.
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?
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.
try this one
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..
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
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.
i hope now you are get the result as you expected
regards
karthick
I told you before your issue will be resolve by using the boolean variable. anyway you got the solution.
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.
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.
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
@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
Hi, sure. Thank you in advance.
now tell what are you trying to do where in this OML file
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.
I will try this first. Thank you.
first check that one and tell me what will happens
thanks