In Goal 2, you added a subsummary part to your Main List layout, but it doesn’t display unless you sort the data by the Last Initial field. Let’s create a script to store the sort settings so that it's easier to perform.
Create a one-line script that sorts your main table records, causing the subsummary part of your Main List layout to be displayed.
Create the script
- Make sure you are viewing your Main List layout in Browse mode.
In the example file, this layout is called “Contact List”.
- Choose the Scripts menu > Script Workspace… ⇧⌘S or Ctrl S
A Script Workspace window appears.
- Create a new script by clicking the + button above the left panel, or by pressing Command-N (OS X) or Control+N (Windows).
Note that the bug button on the right only appears in FileMaker Pro Advanced.
Your new script appears in the center pane of the Script Workspace. It is currently named "New Script" but FileMaker Pro is waiting for you to rename it.
- Name your script: Sort [Main Tablename], then press Enter to save the change.
The example solution calls this script “Sort Contacts”.
- In the progressive search box of the right pane, type: sort
Two script steps have the word "sort" in their name, so they are displayed.
- Double-click the Sort Records script step in the right pane.
The script step appears in your script in the center pane.
- Click the blue gear to specify the script step options.
A popover appears.
- Select the Perform without dialog option.
Normally, a dialog window is displayed asking the user how the records should be sorted. When this option is selected, this dialog window is suppressed.
- Select the Specify sort order option.
A Sort Records dialog window appears.
- Move the “Last Initial” field from the fields on the left to the Sort Order list on the right.
- Repeat step 10 for the “Full Name” field.
- Click the OK button to dismiss the Sort Records dialog window.
- Close your script by Edit Script… window by clicking on the X that appears when you hover over the script name.
A dialog window appears asking “Save changes to ‘Sort Contacts’ first?”
- Click the Save button to save your changes.
The dialog box disappears and the script disappears from the center pane.
Test the script
- Choose the Records menu > Unsort
The records are returned to their original unsorted state and the subsummary part disappears. If this menu command is grayed out, the records are already in this state.
- In the left pane of the Script Workspace, select the “Sort Contacts” script.
- Click the "Run" button above the left pane of the Script Workspace.
The script runs. Your found set should now be sorted, causing the subsummary part to display the last initial headings.