Merge Lists while Retaining Duplicates

Hey Everyone…

Do you know a way to merge two lists WITHOUT removing the duplicates?
(The lists are stored and manipulated as states…)

So if I have lists:
Apple, Apple, Pear
Apple, Pear, Orange

I want the result to be
Apple, Apple, Pear, Apple, Pear, Orange


1 Like

Were you looking to save (or display) the merged list as a single string? or do you want store the data inside a bubble db entry list or page state list? It has been my understanding is that in bubble a list of [texts, numbers, things, etc] does not allow for identical objects to be stored inside. I don’t even think your hypothetical list #1 is even possible?

Bubble lists are distinct from an array in JavaScript, and most other programming languages. I have my guesses as to why lists are implemented this way, but nevertheless I believe it is a hard limitation. I hope someone can correct me on this because I too desire this functionality, but am not holding my breath. :slight_smile:

Hey Jon, thanks for your reply…

My user record has a list of events, and I have just successfully been able to assign the same event to it twice within the App Data area of Bubble… so it seems Bubble does allow a list to contain the same thing twice.

Maybe the solution we seek exists in some way…?

I’m wondering if some of the Bubble gurus have an idea… maybe @romanmg, you can help us…? :slight_smile:


Yeah, you can do it in the Editor, but I don’t know a way to replicate in the Workflow.

Ideas …

Store the Unique Ids in a list of Texts
Set up a “link” table so resolve the many-to-many externally.

So “User Events”

User : Type User
Event : Type Event

Hey @NigelG, thanks for your reply!

Yes, I have that text list running alongside in a state already as I am working on the questionnaire for the booking form and that seems the only sane way to save all the answers in real time.

I’m trying to keep a score of the total value of what people have ordered, and it is so much easier with a list of my price things… I can’t easily do that with a list of text.

It just means they can’t order two of the same thing if I can’t have the same item in a list twice… And I really want to avoid going to the database while they are filling in the form…

Oh well…