Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sorting function

Featured Replies

Is there a way of obtaining whether a recordset is sorted in acsending or descending order?

I've looks through the list of the Get commands, and cant seem to find it. The reason I want to know this is because I have navigation script which allows the users to go to the next or previous records.

When the records are sorted on a numertic field, I tend to use decending (as I want the highest number at the top), and at this point the navigation buttons work backwords.

Thanks for any advice

There's no function for this. If your sorts are scripted, you can set the sort choice in a global.

  • Author

Thanks Ender,

As I've got everything in one file, I think I'll script it in a global variable. I dont fancy creating a extra field.

Its a pity theres only get(SortState), it would be much more useful if you could get the order nand possibly the field name without all these work arounds.

Well, it's not as simple as that. Suppose you're sorting by more than one field, maybe sorting by Date (Descending) then Name (Ascending). Any function to disect this sort state will necessarily have to parse out the field and its ascending/descending/value list choice.

If you're doing it by your own method, you can ignore the first sort field in some circumstances, or ignore the second sort field in others. For example, if you have a list of Contacts that has buttons to sort it by:

1. Name Last, Name First

2. Company, Name Last, Name First

3. Date of Last Contact, Name Last, Name First

4. Sales Person, Name Last, Name First

With this, the actual sort options are somewhat complex, but for our purposes, it's only necessary to know if they are sorted by "Name", "Company", "Date", or "Salesperson", and Ascending or Descending. So I see two globals for this, the Sort_Field and AscendingDescending_Choice. The sort script would then have the 8 sort options, with branching to use the correct one based on the script parameter (passed from the button) and the two globals:

If [ get(scriptparameter) = "Name" ]

If [ $$Sort_Field = "Name" ]

If [ $$AscendingDescending_Choice = "Ascending" ]

Sort [ by Name Last (Descending), Name First (Descending) ]

Set Variable [ $$AscendingDescending_Choice ; "Descending" ]

Else

Sort [ by Name Last (Ascending), Name First (Ascending) ]

Set Variable [ $$AscendingDescending_Choice ; "Ascending" ]

End If

Else

Sort [ by Name Last (Ascending), Name First (Ascending) ]

Set Variable [ $$AscendingDescending_Choice ; "Ascending" ]

Set Variable [ $$Sort_Field ; "Name" ]

End If

Else If [ get(scriptparameter) = "Company" ]

...

Wouldn't it be simpler to change the navigation buttons when the sort is executed?

In the sort script, include

set $$SortHold; "A"

then for the button(s),

Script -

Navigate(parameter = $$SortHold)

if (Get(ScriptParameter) = "D"

Go to Record [Previous]

Else

Go to Record [Next]

end if

Or am I missing something (again)?

Hmm, your solution brings to question Jalz' statement:

When the records are sorted on a numertic field, I tend to use decending (as I want the highest number at the top), and at this point the navigation buttons work backwords.

What does this really mean? If the records are sorted descending, like:

89

45

23

11

And the user is on "45", then what is Jalz doing for navigation that's backwords? Certainly Go to Record/Request/Page [ Next ] would bring up "23". Isn't this what it should be doing? If not, what would be the point of sorting descending?

Jalz, what the heck is going on over there? :qwery:

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.