Workaround for adding duplicates to a List

We currently can’t add duplicated datatype elements (same unique_id) to a List:

There are solutions for adding duplicated texts and numbers

There are also recommendations for plugins that can handle duplicates in Lists, but they are either discontinued, premium or can only handle texts and numbers:

My questions:

  1. Are there other plugins out there that allow to add duplicated datatype objects to a list?
  2. How can we achieve this by using Javascript?

Depends on your use case but a new data type with fields for the relevant data type and the quantity could work just fine.

Not sure if I understood correctly.

Are you proposing to create several fields in a new datatype so as to store the same element multiple times in those fields?

No… if you want to store a list of Users with duplicate users, create a data type User (List) with fields Quantity and User. Store a list of User (List)s wherever you want your list. If the order of the list is important, then ignore the quantity field and create a new User (List) whenever you want to add a user to a list.

Got it.

This solution will work indeed, but it implies modifying the data model so it’s not a solution in my case

You could make it a list of texts with each object’s unique ID then an _ and random string.

So where UID is the unique ID of your data type:

UID1_gssthju
UID2_agofjdd
UID1_dbncfnr

You can then split by to get a list of unique IDs- just not very WU efficiently.

@adrianCTOBelong, you can use either my Floppy or List Shifter plugins (both of which are found in the Floppy plugin collection) (forum thread) to create and manage lists that contain duplicate items, as mentioned in the thread that you linked.

Floppy was temporarily unavailable while I migrated some of its server-side actions to the new server-side plugin API, but it’s back in the marketplace and installable once again.

Using Floppy’s “RAM List” feature you can add duplicate items to a list and it supports all Bubble data types, including Things. The List Shifter element also has a similar feature (using “Custom List”) but it’s not as user-friendly as Floppy’s RAM List-related actions.

On the server-side, my plugins such as List Popper and List Pusher also enable/support lists with duplicates in them. (Those plugins are available in the List Popper & Friends plugin, which is free, but again they are specifically for backend operations.)

2 Likes

For my implementation of a number, I returned the index as the decimal point using js. Then when using it I used “this things:floor”.

1568.00000
1568.00001
1568.00002

@justinnnnnn, a bit of a hidden feature, but my very lightweight (and free) Polyhedra plugin supports the creation of numeric lists that can contain duplicates, via the “Set/Mod Aux List” action. That action also allows very simple list-wise math operations (not as full-featured as Floppy’s “List Math” action), but you can do things like addition and subtraction.

1 Like

This solution provides you with a list of (duplicated) unique_IDs in the form of a List of text elements, so it will work for some cases.

In my case it is not a solution because I eventually need to store duplicated datatype elements in a List, so even if I have a list of duplicated unique_IDs, I can’t place the elements they refer to in the same List

You can’t (not in Bubble DB)… that’s the very limitation you’ve asked for workarounds for… plug-ins will work for temporary front end data but if you share more about your use case you might get more luck…

The List Popper & Friends plugin is the solution in my case.

I have basically pushed duplicated datatype elements with the “List Pusher SSA” action. You can then access the result via “Result of step X (List Pusher SSA’s Updated List”.

In my case I needed to set the value of a datatype object field, containing a list of Users (the field’s type is “User (list)”), which can be duplicated.

So, I just need to use the “set list” action to dump the “Result of step X (List Pusher SSA’s Updated List” value to the field to have the duplicated elements there.

I meant a list (any kind of list, not the List natively supported by Bubble, which of course can’t support duplicates), sorry.

The List Popper & Friends plugin offers a list that can store duplicated elements, and the “set list” action can be used to set that list as a value a datatype object field. This way you can work with lists and duplicated items without any problem.

Thanks for your other workarounds anyway, they might be useful for other use cases!

Glad that List Popper & Friends works for your use case! One thing to be cautious about, @adrianCTOBelong, is that server-side actions are still rather overpriced in my opinion and can consume a lot of workflow units. It’s just something to keep an eye on if you’re going to be using them a lot. (And it’s always better to do stuff in the front end whenever possible, cost-wise.)