It’s not too difficult…

First you need to establish whether or not the item is being moved Up or Down in the list.

If it’s being moved Up (i.e. to a ‘larger’ position number), then the first thing you need to do is reduce, by 1, all items with Order numbers higher than the moved item’s original order number, up to and including the item at the New position of the moved item.

So, for example, if you’re moving Item 3 to position 9 (in a list of 12), reduce by 1 items 4 through till 9.

Then just set the moved item’s ‘Order’ number to that of the Item it’s replacing (i.e. 9).

If you’re moving the Item Down (i.e. to a smaller ‘Order’ number), then first increase by 1 all items starting with, and including, the new position, up to, but not including, the original position of the moved item. Then change the Order number of the moved item.

e.g. If you’re moving the item at Position 9 to Position 3, first increase by 1 all items currently at positions 3 through to 8, then change the Order number of the moved Item to 3.

And don’t use an API workflow for this - it will result in a terrible UX - use a regular ‘on page’ workflow so that Bubble makes the changes to the client-side representations of the database objects as well as updating the database itself, for a much faster UX.

3 Likes