Incorrect List Items Removed

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:


and:
image

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”:
image

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):
image
image

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?

Cheers,
Rob

Hi @Rob_Dawson ,

Please provide the Application ID of your app and the page where this behavior can be tested so that we can investigate the issue.

Regards,
Viktor

Hi Viktor,

App ID is 612DF17B-0F8F-1F90-FF40-054B83FDF500, page is pgRates.

Cheers,
Rob

Hello @Rob_Dawson!

Could you please try passing the entire object to the item field instead of just the fdItemDisplayOrder value, while keeping the comparator as fdItemDisplayOrder?

Regards,
Alexander

Hi @Alexander_Pavelko ,

I changed it to this:


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?

Cheers,
Rob

What I meant was that you should try passing the entire object you want to delete.
For example, this one:
image

However, since you are likely creating new objects using only the necessary properties, you should pass a similar object in the item field:

Regards,
Alexander

Thanks @Alexander_Pavelko ,

I don’t want to delete from the object you mentioned:
image

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:
image

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?

Cheers,
Rob

Hello @Rob_Dawson!

I understand what you’re aiming to achieve and meant to say that you need to pass the object you want to delete, like so:

or in this manner:

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:

Once you make these changes, everything should work as you intended.

Regards,
Alexander

Hi @Alexander_Pavelko ,

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 :face_with_hand_over_mouth: ). For anyone having the same issue, here is the solution that works perfectly for me:

Thanks heaps for working through this with me!

Cheers,
Rob

1 Like