I am trying to remove an item from a list and an incorrect item (different and random) gets removed when I call the logic. Here’s my logic, called when I select or deselect a checkbox in a repeater block:
When a row is selected, a list (selectedRateItems) is populated with the row data from the repeater block, and the row changes background colour. If another row is then selected, this adds the newly selected row to the list, and this all works correctly. Here’s the output showing it working:
When I deselect one of the rows, I want to remove that row from my list, and the logic does remove a row from the list, but not the one I deselect, instead choosing any random one of the selected rows. Here I deselected the “1.7t Mini Excavator”:
but it removed the row for “Supervisor”. My logic is using a unique value “fdItemDisplayOrder” as the key/value to delete, and I’m capturing that correctly (I believe):
Here’s the line in my logic that does the removal:
I have tried setting the variable “itemToRemove” to null before and after the logic call, but if made no difference, and it appears to randomly select which item it removes - it’s not always the first or last item. The next step in the logic - changing the background colour back to the original colour - works correctly.
Can anyone help with what I’m doing incorrectly with this please?
Could you please try passing the entire object to the item field instead of just the fdItemDisplayOrder value, while keeping the comparator as fdItemDisplayOrder?
and it made no difference - it still deleted a different item. I’m not sure how that could work, as it doesn’t reference a unique value for the comparator to work with? Is this what you wanted me to try?
I don’t want to delete from the object you mentioned:
because this is the reference item that I use to build my dynamic list from. I build my list from selected objects in the Repeater Data Item, and from there I pass these list values to another table. So I need to add or delete the item from my dynamic list below, when it’s selected using the reference above, not from the reference itself. My dynamic list is called:
and the add logic works, but the remove logic doesn’t. This is my problem, and I’m not sure if I’m misunderstanding you, or the other way around. Does this make sense?
However, it might not have worked because I also noticed a typo in the property name of your object.
It’s fditemDisplayOrder instead of the correct fdItemDisplayOrder:
You are a legend! I understand now what you were saying, and this resolved this issue after I fixed my rookie typo errors (I actually found a second one when fixing the one you pointed out ). For anyone having the same issue, here is the solution that works perfectly for me: