Server Side Scripts: Get & Restore Context

Traditionally, performance in computing has revolved around the optimization of bits and bytes — how many can be saved and how efficiently a task can be accomplished. This principle dates back to the era of computers with only a handful of kilobytes of memory, where maximizing efficiency was critical. Fast forward to today, and the same principle holds true. Despite various ways of achieving the same outcome, the ultimate question end-users continue to ask is: 'Can you make it go faster?'

Enter Perform Script on Server (PSOS), a realm where speed becomes almost a certainty. Here, actions occur where the data is stored, eliminating unnecessary back-and-forth between client and server, with the resulting communication involving updating the client's user interface. PSOS becomes particularly advantageous when a client, perhaps viewing a single record, triggers an action which impacts a significant number of records — say, 20,000. In such cases, leveraging PSOS is imperative.

The challenge with PSOS lies in its somewhat invisible nature, requiring troubleshooting and debugging skills to fully grasp. Equally critical is the task of restoring the current client's context, comprising two essential components: the layout (base table and pertinent relationships) and the found set of records. Thankfully, FileMaker offers a built-in mechanism to handle context restoration.

This video, accompanied by a supporting technique file, equips you with two invaluable scripts — one for obtaining and the other for restoring server-side context. Let's learn how to harness the power of PSOS efficiently and restore some context!

AttachmentSize
GetRestoreContext.zip1.73 MB

Comments

Thank you for this, very useful technique.
I've been using another PSOS debug trick for years and it works well. I believe it was Honza that discovered that you can use the Re-Login script step anywhere in the script to make a server log entry with whatever text you want. As there is no such account, the server will log an error which you can view or have sent to you as an email by the server. Very useful.
Re-Login [ Account Name: Whatever you want to check ; With dialog: Off ]

This is impressive, but the sort was really the third piece of context I was hoping for,
and it becomes tedious to make a universal script for context dependent PSOS.
We've had Save Records as Snapshot Link since 11.0
and Perform Script on Server since 13.0.
As this article makes clear, these two script steps were so obviously a match made in heaven.
Tragically, the script step family is dysfunctional, and Server can't just simply open a snapshot link after all these years to establish all the wonderful context provided by Save Records as Snapshot Link.
Thanks, though, for showing a way where there was none.

—Eric @ DIGFM

What's the overhead to Get ( RecordID ) on records in a table when adding records?

—Eric @ DIGFM