this is the wrong order
Looks like you need a field where all listed items of a given package will have a unique common value. Then you can sort by this field first to keep the groups together.
I have been experimenting with all the sort orders I can think of based on your input. I created a script that adds a unique value to the line items that are added as a package. I can get it to sort on that value. I can also get it to sort by my value list "inventory category" but I cannot get them to work together.
For example, I want the "mixer package" and its sub items to always list at the top even if i dont enter it first.
Is "mixer package" listed first in your value list? But then the sub items are sorted by alphabetically by item name?
My inventory catagory list is as follows. The packages are listed before the hyphen. The items below the hypen can be part of the packages or added a-la-carte. I would like the packged items to stay in the order they are added but then that the packages in the order of this values list. Maybe I need a common unique value for each package and then a unique per package field to order them the way i need for each line item, they sort by catagory, then package order and then sub item order.
FOH Processing Package
FOH Mains Package
Assuming that you use a script to add the packaged item, use a global variable $$packagecount to keep track of the number of packages added, inrementing it by one each time the script is performed. The script can enter this value into a field, EntryOrder, of the portal record of the package entry and then also into the same field for the package items. That will number your packages and packaged items in the order that they are added to the portal.
Now you can set up a two field sort order. Specify EntryOrder first and specify descending order to keep the first package and it's items listed first, then add the name field and specify the custom order by value list option for it.
With this two field sort, the first field groups them by package and orders the groups by creation order. The second field then orders the items within each package.
Would this allow me to for example add a foh package to line items and half it with its sub items to sort to the top of the list ( based on the inventory caterogy )
I would like the packaged items to stay in the order they are added
I was reading that as wanting the "packages" not the "packaged items" to be retained in the order entered.
Define an auto-entered serial number in your portal table if you do not already have one. I'll call it "PrimaryKey" here.
Add a text field kept hidden from your portal. When your script adds the package items, have it copy the package name (as listed in your value list) into this field for both the package record and the subsequent package Items.
Now sort with custom sort order based on the value list first, specifying this hidden text field, then specify PrimaryKey as the second sort field so that records within the group will be listed in the order added.
This works perfecly. Thank you for all your help.