I'm new to Filemaker Pro. Just wondering- how do I create a script that I can assign to a button, that will sort a field ascending and descending, depending on which one I'd like?
How will the user choose between ascending and descending?
You could have a button for each.
You could have one button that 'toggles' between the two sort orders.
You could just select the option from a value list and not have any button at all.
You can use the script step: Sort [Restore ; no dialog] to sort your records. This can be a single step assigned directly to the button in button setup... if you use a button for each sort order.
Or you can use a script that uses IF [ ] to select which Sort script step to use so that you get different sort orders.
If [Yourtable::globaltextField = "Ascending"] Sort [Restore ; no dialog ] // specify sorting in ascending orderElse Sort [Restore ; no dialog ] // specify sorting in descending orderEnd If
With YourTable::globalTextfield formatted with a value list, you can use a script trigger to perform this script when a value is selected.
This script 'toggles' the sort order:
If [$$SortOrder = "Ascending"] Sort [Restore ; no dialog ] // specify sorting in descending order Set variable [$$sortOrder ; value: "Descending"]Else Sort [Restore ; no dialog ] // specify sorting in ascending order Set variable [$$sortOrder ; value: "Ascending"]End If
Retrieving data ...