1 Reply Latest reply on Aug 17, 2011 9:09 AM by philmodjunk

    Capture sort order

    john9210

      Title

      Capture sort order

      Post

      FM 11 Advanced. I have a browsed set that can be sorted by a variety of different scripts. I would like to capture the sort order of the browsed set so I can restore it later after running another script. It there a way to capture the current sort order so it can be used in a script?

        • 1. Re: Capture sort order
          philmodjunk

          Since you have scripts that determine the sort order, this can be done. (You can't really capture sort orders generated by the user selecting Sort form the Records Menu.)

          Each time a script sorts your records, store data in a global variable to record the current sort order. Then a script can restore the current sort order by checking the value of that script.

          Here's how I would do it.

          Step 1; Create a Sort Script like this:

          Set Variable [$$SortOrder ; Get ( ScriptParameter ) ]

          If [$$SortOrder = "Name" ]
             #Sort records by Name field
             Sort [ no dialog ; Restore ]
          Else IF [$$SortOrder = "Cost"]
             #Sort Records by Cost field
             Sort [ no dialog ; Restore ]
          Else
             #Sort Records by Margin Field
             Sort [ no dialog ; Restore ]
          End If

          Your original scripts can use perform script to call this script and pass "Name" , "Cost" or "Margin" as a script parameter to select the desired sort order. To resort your records, use Perform script, but use $$SortOrder as the script parameter.

          Hint: with conditional formatting, you can change the appearance of the current sort field or its label text to show the user which field is currently the sort field.