Minus only one item in a list

I have the situation described above. I have two lists

List A:

  1. apple
  2. pear
  3. pear
  4. banana

List B:

  1. apple
  2. banana
  3. pear
  4. apple

Each list is displayed in a repeating group. When a user clicks a button in a repeating group cell, the item is removed from that repeating group and added to the other repeating group. So, if someone clicks the button in List A 2., 2. should be removed from List A and be added to List B.

However, :minus item removes both instances of ‘pear’ in the list.

Anyone know how I can get around this? ‘The workaround (again, not a workaround as the above is expected) is to return items number 2 to :count’ didn’t make sense to me so if anyone can explain that’d be great :grin:

Yes… indeed… whilst lists can have duplicate values in Bubble, the moment you do any kind of processing on that list (i.e. :minus item) all duplicates are removed - hence what you’re describing here.

One simple workaround is to use a list of texts and just ensure each item is unique… (even if what you display is not).

So give each item a unique identifier (such as a number)but hide that from the display. That way there are no duplicate items in the lists (even though it looks like there are).

Obviously, as you’re using Texts there may be a bit more work involved in the rest of your logic to match the values as needed, but it gets around the issue of duplicate items.

Here’s a simple example:

Duplicate List Items (bubbleapps.io)

2 Likes

Thanks!

Actually… there is a (probably) simpler way, based on @keith’s solution from the post you linked to (although your question is slightly more complex than the question in that post, so the solution is also more complex)…

I’ve added it as the ‘Alternative Method’ on that demo page…

3 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.