Hi all,
I'm encountering the error message 'List is being iterated: indexOf is not allowed.' Here's the situation: I have a dropdown with values obtained from a list. When a user selects an item and saves it, I want to remove that item from the dropdown. I've tried using two for loops and the list's IndexOf method, but I'm still facing the error mentioned above.
I appreciate any assistance you can provide.
Hi @Cuong Su ,
I propose this easy solution :
Only in cases where this approach yields performance issues, look at doing it yourself with list manipulations on client side.
In that case, above reply of @Arun Rajput can help you on your way, but is probably only half of the story : you didn't mention this, but your user might at some point be able to deselect what was previously selected, and you need that thing to re-appear in the dropdown ?? So what are you going to do then, add an item to your list on client side ? So you know the id but where will the name of that item come from, and where in the order of the list will you put it ?
If I would try to do this on client side (only in extreme cases, doing just a refresh of the dataAction is far far far easier) I would probably
Dorine
Appreciate your support; it's very clear. Because the first time I used static aggregate as a list, it was really hard to modify attributes. After I changed to using a normal aggregate and followed the instructions in your post, it works now.
I really appreciate it.
Hi @Cuong Su
Inside the save button logic first find index of that selected value using "ListIndexOf" action
Which you can find inside System module. Once you got the index now use "ListRemove" action which removes value using Index/position.
Best
Arun
Thank you for your support
Hello Cuong,
If the list is been iterating and and one of the item is getting removed from the same list inside for each then system throws this error.
To avoid that use list local variable on for each and remove the item from that local list and assign filtered list to another local variable and use that variable in dropdown.
This way you won't get this error.
Updated last post with OML, you will find it in Dropdown screen.
Hope this helps,
Komal
Really appreciate your support. After I added a local variable to a list instead of using the aggregate directly, it now works.
Thank you so much.