'Sort Records' vs. 'Sort Records by Field'

The Sort Records by Field script step, available in FileMaker 12 (and above), might be a useful refactor from the earlier Sort Records script step when you:

  • want more readable code (see below)
  • are only sorting by 1 field (for example serial number, RecordID, other?)
  • want to “Keep records in sorted order”


  • When was this checkbox added?
  • What was the default before?


1 Like

The FileMaker 12 help makes a reference to this (see here).

That said, it is unclear if the feature was introduced in FMP12 or started to be documented at that specific location from FileMaker 12.

Basically, this was introduced on or after sub-summary parts would display in browse mode (prior to that, they displayed only in preview more). That feature, made it so FileMaker's default sort behavior would be to keep records sorted even if you alter a record's data that is targeted by the sort order (if a first name "Sam" is renamed "ZZZSam" and your records are sorted by first name, FileMaker will push the record where it belongs in the sort order.)

Prior to all this, if you were to edit a record's data that was involved in the sort order, the record would not budge and the sort order would become "semi-sorted" (what you get today if you uncheck that checkbox).

I believe the change to the sort behavior was initially called "persistent sorting" or "automatic sorting". I also think this change was present in FileMaker 10, but do not know if it was in the product prior to that.


P.S. Thanks for the walk down memory lane!


The Docs say that it was first in v12. New features in FileMaker Pro 12

I remember it being a very disruptive change ( where did my record go? ). I don't remember it being in v10.

The previous behaviour was to leave the records in the positions they occupied before you edited the record data. If the edit changed any of the fields used in the sort criteria the Sort state became "semi-sorted".

1 Like

There is a nice thing about "Sort Records by Field" : the field used to sort the found set can be "dynamically" defined using a variable, as long as the field has an object name specified in layout mode. The script would look like this:

  • Set Variable $sortFieldObjectName with the name of the layout object name set to the field
  • Go To Object (calc = $sortFieldObjectName)
  • Sort Records by Field

Still, this is not flexible enough when requiring sorting by more than one criteria (example, a report with more than one subsummary part, and need to hide or show parts depending on sorting fields). This has to be "hardcoded" using the traditional "Sort Records" script step, that means having to create a script step for every single combination of multiple fields sort options.

It would make sense to be able to specify the sort fields combination "by calculation", so only one script step would be necessary for unlimited sort fields criteria combinations.

My preference would be a "Sort Records by JSON" script step, or a "specify JSON calc" checkbox in the existing "Sort Records" script step. The sorting JSON syntax is actually already used for the Data API queries, and in the "Execute Data API" script step (sort query is specified using JSON). So it would be great if we could use the same syntax to specify the sorting of the found set, by setting the same JSON syntax as a calculation in the "Sort Records" script step.

There was a request about this in the Claris Community ideas section, feel free to vote!:


Good idea. I’ve read your post and immediately voted there. :grin:


We use this technique for single sorting by fields that are local to the layout context.

For fields that are NOT local, for example from a parent record, this can fail if the relationship is not yet established...so use with care!

1 Like