Remove element by index in list

I would like to remove an element (the last one in my case) only by index. But Bubble doesn’t allow me to write :count-1


I didn’t find any solution on the forum.
There is a workaround here, but it doesn’t work for me.

I’m thinking of creating a specific state “count-1” where Bubble allow me to write :count - 1. But it seems quite complex for something that simple, am I missing something ?

I understand that is not quite an issue since the lists from Bubble don’t contain duplicates, but still.

Thank you.

Create new group element with datatype is number - which contains the total number count.

use this element on the :items until#Group SS’s Number.

1 Like

So creating a hidden group elelement just to contain the :count-1 ?
If so, I did the same but with a state.
Is this what you mean ?

@BudSpaces You could also do:

“Easylist Path group’s list :minus item Easylst Path group’s list :last item”


Coaching No Code Apps
Join our Facebook group for insider access to no-code development
Get professional development services
Enroll in expert-led courses and products

1 Like

@gaby beat me to it, but building on this a little further:

If I read you right, you have a list (let’s call it THE_LIST) and you want to turn that list into the same list… just without the last item. Correct?

If so, that’s just:

THE_LIST :minus item THE_LIST’s :last item

While Bubble isn’t a 100% array-oriented language, it gets some parts right, and this is one of them.

(Similarly, to answer the question posed in your post’s title: to remove an item by its position (1-based index) in THE_LIST, you simply do:

THE_LIST :minus item THE_LIST’s :item # position

And if this syntax seems strange to you… Well… This is syntactically a bit more straightforward than the JavaScript .slice() method, right?

It is slightly frustrating that you can’t nest THE_LIST’s :count (due to limitations - that are fully understandable when you look at them critically - in the expression builder) inside of an expression that already references THE_LIST. Well, that’s drag ‘n’ drop programming for you. :man_shrugging:

1 Like

Nope, you are right…that is the way to do it if you don’t want to use a plugin for math.

I use the technique you mention with custom states a lot…I usually use them in conjunction with the current cell’s index values to set up some different behaviors with R.G. data.

My advice is be prepared to think outside of the box a lot when trying to force bubble to your will and get it to do what you want…you’ll usually prevail and find some way around the limitations.

1 Like

Yeah, sorry forgot to precise that it’s an easy list, so there are duplicates. Doing this method will remove all similar elements from the list.

You’re right. Although I wanted to make the “position” variable dynamic.

Like, I wanted to delete the third last element with a variable list size. I think the states method seems the best solution right now.

Thank you for your detailled response !

Thanks for the piece of advice. I will remember it while building :slight_smile:

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