How to add duplicate items to a list of texts?

So I have a DB entry which contains flight routing. On the form when the booking is created, the user selects one-way, return, or multi-leg booking.

Below this is the boxes to select the locations for each leg.
image

When updating the Booking Routing field, which is set to be a List of Texts, when I select ADD, it won’t add the text if it already exists in the list.

for example, if the user selects Return, I want the Routing field to contain 4 items. The origin, the destination, then the destination then the origin again, because it is a return flight.

But, if I just try to add the destination and origin to the list again, it doesn’t add them, presumably because they’re already there.

How do I get around this? Should I use “set” list instead? I was messing around with that but I can’t figure out how to add each dropdown item. The statement just turns red all the time…

@tonymoulatsiotis

Have you considered creating an object (data type) for this?

Objects are unique :grinning:

This is a MAJOR problem for me and my app. I cant add duplicate items to the list either. Have not found a solution and my app has since stalled. I had to cancel my subscription because without this my app is pointless. I wish Bubble could make this work. or someone can find a reasonable work around.

The duplicates in a list - what I’ve found is that you can have duplicate numbers and texts in a list - if you use “set list”. I use it for holding scores, lists of email addresses etc where I want to hold duplicates. I’ve previously tried a lot of messy ways - eg storing a CSV string., storing JSON - very painful.

I made it a free plugin. Gives you a server side action you can use to manipulate your list before you set the list into your database list type.
https://bubble.io/plugin/list-inserter-1644710329977x707267593195487200

Try it out here.
https://list-inserter.bubbleapps.io/version-test?debug_mode=true

Keith’s List Shifter - that will probably do it also but my particular case I wanted to be able to grow the list automatically when required.

Might help you. Good luck.

4 Likes

Wow this sounds great… I’m going to try this pluggin out… hopefully I can get it to work. FYI, I tried all the messy ways too and I gave up. I’m excited to try this. Thanks for the info.

Cool - any feedback or suggestions for improvements ping me - I’ll fix it up.

I’m finding I’m adding handling for null lists etc as I use it in anger

Hey Linday i’m starting to play with this now.

Im trying to keep a list of scores for each user. This list grows as the users have more scores and the scores can be duplicates.

This is what I have:

  1. Original list = Current users score (this is the field I want to add the score to)
  2. Position = ? I’m confused here , This number is dynamic, it depends how many scores the user has. Should i try the function count current list and add 1? Will that work with ur pluggin.
  3. Value = value I want to add ( simple enough)
  4. Pad = im assuming this Is this if the text box is empty…

Really just need your input on the second thing please and thanks.

Cool !
position - the position in the list (1 is the first position) - yes if you wanted to add it to the end of the list - just do list count + 1
Pad - if the position is beyond the length of the list then that value to set for the missing values.

Eg my original list is 3 scores
5,4,3

If I add 2 to position 4 I will get a list
5,4,3,2

If I add 2 to position 10 I will get

5,4,3,2,0,0,0,0,0,2

I saw a bit of weirdness with adding 0 to the end of a number list - didn’t have time to dig deeper - so I made the pad value -1 - sidestepped the weirdness

So it’s a bit hackie but isn’t everything with bubble

You could save the string and the time separated by a specially character (you could even use a counter so you always have an original number, then use split by:first item to retrieve it

Example

This text€12:44:34 22/2/2022
This text€12:44:85 22/2/2022

Then do a split by:€

i cant get you pluggin to work… i dont know why : (

If you share your app and let me edit it I can take a look. Switch to PM if you want.

I feel your pain and hopefully you can still see this message!
After a lot of fiddling, I found a solution. I had the same issue when trying to assign line item values to an invoice (for example the user wants to use the same line item for multiple dates)

SOLUTION:
First I created a user field called “count” in the database. Then I created a user field as a list where I can store the values temporarily. eg: Current User: Line items

Then I trigger an event where:
User count = current users count+1
Make changes to a thing: Current user Lines = Current user lines + item you want to saves value #current users count (which starts at 1)
Then I trigger the second action but only on the condition that value count>current users count.

On the second trigger, I use the same:
Current user count = current user count +1 (which is now 2)
then it repeats itself and I link the second trigger back to the first trigger on the same condition (that value count > current users count)

Just make sure on page load you reset current users count, and the value field.




you can see it saves duplicate data to the database:

Thanks a lot :pray:

1 Like