The attached file demonstrates a technique for opening/closing areas of a record, allowing a user to hide the information they don’t want to see.
FileMaker File: DisclosureAreas2.fp7
- Sub-summary parts. This is the essential ingredient. FileMaker conditionally shows and hides these parts depending on the current sort criteria, doing the heavy lifting for us.
- Sort fields. Each sub-summary part must be sorted by a unique field. We don’t really care what the value of the field is, so I’ve leveraged the spacer fields that we typically have hanging around anyway (to separate different types of fields in the field list). Renaming these with a number component helps make the button parameters more readable.
- Sort script. FileMaker doesn’t allow us to sort by indirection, which can make for a convoluted conditional branching statement to effect our desired sort. Luckily, on the Mac OS we can employ AppleScripting to build more dynamic sort statements.
- Drag-and-drop. This technique has been evolving in the community since the introduction of script triggers. The nuance here is that we’re dragging from one part to another, rather than from one record to another.
- Mac OS only, since the solution employs AppleScripting.
- The sort fields must be on the layout for the AppleScript to work. I’ve stacked these together in the top-right corner of the layout.
- The sub-summary parts need to either be all leading, or all trailing, otherwise the drag-and-drop won’t work when dragging from leading to trailing, and vice versa.
- Sub-summaries only work in List and Table views. Since what we really want is Form view, I’ve isolated a single record with the opening script, and displayed it in List view. A custom menu prevents the user from toggling views. The next step (not present in this solution) would be to override the record navigation, allowing the user to quickly hop from record to record, but without having more than one record in the found set.
- I’ve used Substitute as my function of choice to quickly swap field names in and out of the list of sort fields. This means the field names cannot be pattern matches of each other (e.g. MY_FIELD_1 and MY_FIELD_11 would pose a problem). My leading and trailing underscores in the field name solves this issue.
- The drag-and-drop container sits behind the disclosure buttons. If the user clicks on the container and then tries to click the overlaying disclosure button, nothing will happen. An OnTimer script helps to ensure that the user’s cursor doesn’t linger in the enterable container field.
- Custom functions are great! Much of the utility functionality has been abstracted into custom functions, such as the parameter passing (courtesy of SixFriedRice), so be careful when you copy and paste elements, as you’ll need to copy the functions first.