I'm trying to set up a system where a user can re-order items in a portal in any way they want.
I've set up a variable in the parent table called %componentCounter which counts the number of associated child records. Then in the child table I've got a field called %listPosition which keeps track of where in the list the current record sits. The theory is that the user can then use Promote & Demote buttons in the portal view to move the records around.
Now I have two problems:
1 If the list becomes corrupted by a user deleting a record or some other unforseen eventuality, like manually adjusting %listPosition, I need the system to be robust enough to be able to rebuild the order. It could perhaps order the items by record creation date or alphabetically, then recreate that sorting in the %listPosition variables, for example. I don't know how to do this.
2 I can write a function that adjusts the %listPosition field of the current record, but then finding the record that is one above or one below the current record is something I haven't yet been able to do. I've tried searching for the record with the same parent id and the particular %listPosition value that I want using Perform Find, but it always tells me that no matching records could be found.
Essentially, I need a way to traverse through the portal records in the order that they are currently displayed, or a fast way of searching for and accessing the next/previous record in the list.