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

Sort Records by Field

Sorts the records in the current found set according to the context of a specified field.

See also 

Options 

Specify target field specifies the field you want to sort by.

Ascending displays data in ascending order.

Descending displays data in descending order.

Associated value list displays data in the order determined by the value list associated with the field.

Compatibility 

 

Product 

Supported 

FileMaker Pro Advanced 

Yes 

FileMaker Go 

Yes 

FileMaker WebDirect 

Yes 

FileMaker Server 

Yes 

FileMaker Cloud products 

Yes 

FileMaker Data API 

Yes 

Custom Web Publishing 

Yes 

Runtime solution 

Yes 

Originated in 

FileMaker Pro 12.0

Description 

Sorts the records in the current found set according to the context of a specified field, letting you create scripts that behave similarly to interactively using the shortcut menu in Table View. If you do not specify a field, the script sorts by the field that is active when the script runs. If there is no active field when the script runs, FileMaker Pro Advanced displays an invalid sort order alert.

Tip  You can find the records you want to sort (using Perform Find script step or Show All Records script step) before using this script step. You don't need to use the Enter Browse Mode script step or Go to Record/Request/Page script step after using Sort Records by Field.

Example 1 

Sorts the current found set by the active field. Can be started by the OnObjectValidate script trigger to maintain the current found set's sort order when field values change.

Sort Records by Field [Ascending]

Example 2 

Shows invoices for the current customer ID, with the most recent invoice listed first.

Find Matching Records [Replace; Invoices::Customer ID]
Sort Records by Field [Descending; Invoices::Invoice ID]

Related topics 

Sort Records script step

Script steps reference (alphabetical list)

Script steps reference (category list)