Sequential renumbering of things?

Ok brains trust…

How would you go about sequentially renumbering something?

First instance say I have items# 1-6 and I delete item#4, how would I go about renumbering the list 1-5 with items#1-3 staying the same and items#5-6 renumbering in order? #5 becomes #4, #6 becomes #5 etc.

Thank you muchly!

Hi there, @equibodyapp… if I understand your post correctly, the “trick” is to make changes to a list of things before you delete item #4 because you need that item to be able to define the list of things that need to be renumbered. So, you would make changes to a list of things where the things’ numbers are greater than the number of the thing being deleted, and the change to make is to subtract 1 from the number of each thing in the list. Then, when that step is complete, you delete the thing that needs to be deleted (in this case, item #4). Make sense?

Hope this helps.

Best…
Mike

1 Like

thanks @mikeloc!

so say I have a RG and a delete button per line…when delete button is clicked the WF would be something like this:

  1. Make changes to list of things > RG list of things > item# = ‘item#-1’, only when item# > current cell’s item#
  2. Delete a thing > Current Cell’s Thing

That’s actually really simple :rofl: :see_no_evil:

1 Like

What about using the List of Number element from the Toolbox plugin? You can use that to count the number of records in your lookup. When your RG loads, you can use the the ListofNumbers as the datasource for a text element in your RG. It will number each row in your RG. When you delete a record, it will remove it from the lookup thereby changing the ListofNumber count.

Just my way of attacking this.

Thanks @jasonh, that’s certainly another interesting way of doing it :slight_smile:

So you wouldn’t have the item# saved in your database at this point?

My use case is something like this:
Say you have a map image, you want to drop markers on the map wherever you click, then you want to have these markers numbered so that you can reference them in a table under the map with more information like name/description.

Currently this is all saved in the database as users keep ‘drafts’ they can revisit multiple times for editing until ready to publish.

Would the list of numbers element keep everything numbered the same each page load for referencing purposes?

It will number them the same way as long as you perform the lookup the same way every time that will not change (i.e added dated).

Another way, and much simpler, is to just use the cell index as the number. Again, as long as you do the lookup the same way. It should work.

Well the RG is sorted by item# so it lists it in number order :sweat_smile:

But sorted by created date could give the same outcome :thinking: Although users could create multiple markers in the same minute - would I need to create a new field in the datatype for a UNIX timestamp to be safe do you think?

But you are right, cell index would be much simpler :smiley:

Bubble’s timestamp can be formatted as Simplified Extended ISO, 2021-02-24T19:49:20.387Z, so that should be sufficient.

Ah yes - thank you!! :slight_smile:

I have a pretty simple setup, where i have a repeating group, which has text field with “Row number” property set to “current cell’s index - 1” (Cause i want my count start with 1, not 0. But i can’t make it renumber when i delete a row. I think i’m struggling to give it required conditions. Can anyone help me with this?

Demo page here: https://marvic-calculator.bubbleapps.io/version-test/console_new_number?debug_mode=true
Editor: Marvic-calculator | Bubble Editor

I’m setting an action on “Delete” icon in a row.