sort Selection should be a field with global storage enabled so that it stores a single value for all records in your table. Either that or replace it with a global variable.
Thank you for this answer! It worked, but now I have another issue. "Sort List Key" is a calculation where the result is text. I also want the option to sort the records by date. I tried adding another field "Sort List Key Date" which is a calculation: GetField ( Sort Selection ) but instead of being text, I made it a date field, but I do not know what to do next to make the records sort in this way. Do I need to add something to the script such as If the sort list key is a date, sort by another field? Everything is still the same from the original script.
If you grab the date field as:
GetAsNumber ( DateField)
it will sort correctly. If you are going to have a really HUGE span of dates you make have to pad the front with a couple of zeros.
What is the purpose of having the Sort List Key field? What prevents you from just sorting directly on the fields that Sort List Key references?
Usually, a "sort list key" approach is used for getting a portal to dynamically sort--it's not normally needed for sorting a found set of records on a layout.
I want to search a range of dates. Then, with those found records, I want to be able to sort them in a number of ways from a drop down menu including Last name, Category or client, date they became a client, etc. The sorting only works for text based options, though, not dates, and I want to be able to do both from a single drop down menu. Can this be done?
But you only need text here to control which sort is performed:
If [ipot1::Sort Selection = "Last Name"]
Sort Records [Restore; No dialog] ---> Here I specified sort order by Last Name
Else If [ipot1::Sort Selection = "Date"]
Sort Records [Restore; No dialog] ---> Sort By Date
Sort Records [Restore; No dialog] ---> Here I specified sort order by Sort List Key and under Last Name