Reference > Script steps reference > Found Sets script steps > Sort Records
 

Sort Records

Sorts the records in the current found set according to specified criteria.

See also 

Options 

With dialog specifies whether to display a dialog box when the script step is performed, allowing users to enter different sort instructions.

Specify sort order allows you to create a sort order and store it with the script step (Restore indicates a stored sort order). When Specify sort order is not selected, FileMaker Pro Advanced uses the most recently performed sort instructions.

Keep records in sorted order places a new or changed record that’s in sorted order into the adjusted order after the record is committed. When this option is not selected, new or changed records stay in the same position in the sort order until a find request is performed or the records are sorted by different criteria.

Compatibility 

 

Product 

Supported 

FileMaker Pro Advanced 

Yes 

FileMaker Go 

Yes 

FileMaker WebDirect 

Yes 

FileMaker Server 

Partial 

FileMaker Cloud 

Partial 

FileMaker Data API 

Partial 

Custom Web Publishing 

Partial 

Runtime solution 

Yes 

Originated in 

FileMaker Pro 6.0 or earlier

Description 

Find the records you want to sort (using Perform Find script step or Show All Records script step) before using this script step. If you sort a repeating field, FileMaker Pro Advanced sorts on only the first entry in that field. You don't need to use the Enter Browse Mode script step or Go to Record/Request/Page script step after using Sort Records.

Each Sort Records script step can store a unique sort order; the sorting instructions are stored with the step, not the script. You can use this step several times within the same script and store a different sort order for each occurrence.

Notes 

Items in the sort order that aren’t valid when the script step is performed are ignored. When you specify a sort order in a database containing multiple tables, FileMaker Pro Advanced stores the table name for each sort field in the sort order. For example, a sort order using the Last Name field of the Contacts table is stored in the sort order as Contacts::Last Name. If the Sort Records script step is performed when a table other than Contacts is the active table, Contacts::Last Name cannot be evaluated, and is ignored in the sort order.

Server-side scripts, the FileMaker Data API, and Custom Web Publishing run this script step as if the With dialog option is set to Off, so you must use the Specify sort order option to save the sort order in this script step.

Example 1 

Goes to the Invoices layout, performs a find, sorts the records, then goes to the first record in the found set.

Go to Layout ["Invoices"]
Perform Find [Restore]
Sort Records [Restore; With dialog: Off]
Go to Record/Request/Page [First]

Related topics 

Script steps reference (alphabetical list)

Script steps reference (category list)