AnsweredAssumed Answered

Toggle sort order

Question asked by InvectusIlumni on Jan 13, 2011
Latest reply on Jan 13, 2011 by philmodjunk

Title

Toggle sort order

Post

Hi guys --

I've looked into this post here: Button to alternate from Sort Ascending to Sort Descending to write a script that toggles sort order for a given field, but I still need some advice.
I have many list-view layouts and each has at least 10 fields that I'd like to sort. The solution discussed in 
the post above would be great if I only had 1 or 2 layouts, but I don't think it's very efficient to create 7 different scripts that only differ from one another by one small element
In the script below, I was wondering if there was a simpler way to specify the field to be sorted without rewriting the entire script for every single field.

If [ PREFERENCES::text_sort="Ascending" ]
Sort Records [ Specified Sort Order: TRANSACTIONS::transactionid; descending ]
[ Restore ]
Set Field [ PREFERENCES::text_sort; "Descending" ]
Else If [ PREFERENCES::text_sort="Descending" ]
Sort Records [ Specified Sort Order: TRANSACTIONS::transactionid; ascending ]
[ Restore ]
Set Field [ PREFERENCES::text_sort; "Ascending" ]
Else
Sort Records [ Specified Sort Order: TRANSACTIONS::transactionid; ascending ]
[ Restore ]
Set Field [ PREFERENCES::text_sort; "Ascending" ]
End If

Outcomes