9 Replies Latest reply on Feb 8, 2012 5:48 PM by ericjlindholm

    Custom Sort Orders

    ericjlindholm

      Title

      Custom Sort Orders

      Post

      I have a script that automatically adds line items if a "package item" is created.  it works perfectly until I try to sort my line items based on the inventory catagory ( first image).    In stead of listing all the amps right after the rack they are contained in, it then lists all the amp racks and then all the amps total.  I do need to sort by category but also need the packaged items to stay together.  I was thinking about adding a field to the inventory item that adds the same new number to the line item in the packge and adding a sort layer.  Any ideas?  Thank you.

      proper_order.jpg

        • 1. Re: Custom Sort Orders
          ericjlindholm

          this is the wrong order

          • 2. Re: Custom Sort Orders
            philmodjunk

            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.

            • 3. Re: Custom Sort Orders
              ericjlindholm

              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.

              • 4. Re: Custom Sort Orders
                philmodjunk

                Is "mixer package" listed first in your value list? But then the sub items are sorted by alphabetically by item name?

                • 5. Re: Custom Sort Orders
                  ericjlindholm

                  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

                  Monitor Package

                  Distro Package

                  Snake Package

                  Work Case

                  Stand Package

                  Lighting Package

                  SI Pacakge

                  -

                  Console

                  Amp rack

                  Amps

                  Microphones

                  Cables

                  Speaker Cab

                  Labor

                  Processor

                  Lighting

                  Wireless

                  Video

                  SI

                  Consumables

                  Additional Gear

                  Labor

                  Shipping

                  • 6. Re: Custom Sort Orders
                    philmodjunk

                    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.

                    • 7. Re: Custom Sort Orders
                      ericjlindholm

                      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 )

                      • 8. Re: Custom Sort Orders
                        philmodjunk

                        Oops, I misinterpreted the info on the sort order that you wanted. Embarassed

                        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.

                        • 9. Re: Custom Sort Orders
                          ericjlindholm

                          This works perfecly.  Thank you for all your help.