Claris has departed from the tradition of sequentially numbering its product releases. They decided to use the year of the release in the name of their latest release – FileMaker 2023. Yet, a word to the wise, while the name of the software is FileMaker 2023, the version number internally to the software is FileMaker 20.x.x.
Claris FileMaker 2023 includes many new features. The Perform Script On Server with Callback (PSOSWC) function is arguably the most exciting new script function we've seen in years.
This script step instructs the server to trigger a script back on the client that initiated the event after performing a script on the server, thus, a callback. Nonetheless, there are a few technical details/caveats to be aware of as we explore this feature for our apps.
Why is this exciting for FileMaker developers? Well, sending a script to PSOS before was a bit of a black box. Unlike using the script debugger in the client, we can't step through a script and see the errors that it returns. We can refer to the log on the server and see them there, but that can often be tedious to sift through, and sometimes our access to the server is limited. Using a callback, we can script error trapping that can be sent back to the client with the native FileMaker error codes. We can also customize the data we send to test if our script is doing what it should while running on the server. Of course, it was possible to do this using Script Results before, but the callback is more elegant and easier to implement.
Another use case for this feature, which can benefit developers and end users alike, is when we have a script that requires a long time to run. Rather than tie up the client with this activity, we can send that script to run on the server. Then a callback script can notify the user when it's complete.
So how do we set this up? To use this feature, we need three scripts:
As a demo/test, we've created a sample file with one million records. We've written the three scripts above.
The next test was to run the PSOSWC script step. Seeing it fire off was a bit disconcerting, with no expectation that we had to wait around for it to complete. But the minute it started, we could see records updating in our client. We left FileMaker running but proceeded to do other things like check e-mail. We could have been using FileMaker as well at the same time. Within about 5 minutes, our last script fired, and a dialogue box popped up to alert us that the script was complete. We are amazed at how productive this technique is. It's like having another computer at our disposal.
First, we limited the record count to 100,000 to speed up the processing time for this demonstration. Second, we captured the replace operation's start and end times to record how long it takes to run this script. This script is an example of local variables and data that will not be stored but are still valuable information that we can distill and transmit. We'll pass the total elapsed time to the callback script and display that in the pop-up dialog box.
Join our mailing list to keep up with the latest FileMaker development trends. And if you need help incorporating any of these features into your custom apps, don't hesitate to contact us about our mentoring or consulting services.
This article is also published on FileMakerProGurus.com.