Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6720 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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

Posted

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.

Posted

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" ]

...

Posted

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)?

Posted

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:

This topic is 6720 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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