Trigger a script on another client

Trigger a script on another client

04/07/2014 | Jan Stieperaere

Concept

The technique can be used to trigger every script on an other user’s client but as well for example on a robot client who can then perform your specified actions.

And this can be done on-click and without an on-timer script running in the background. It can be embedded in any FileMaker project. And it works in FM Go and in WebDirect!

The only requirements are that the file must be hosted by FileMaker Server and must be open on the other client. A ‘listening’ layout must be active, but you might open a hidden window and switch to that layout.

The OnRecordLoad Script Trigger

The key technique used to trigger a script on an other client is the OnRecordLoad script trigger.  This script trigger is not only fired off when loading a record, the common use of the trigger, but also when deleting an active record! Because the active record was deleted, another record is loaded… (or no record, when no records in found set anymore).  At that moment, a dispatching script can check if some actions must be performed.
The nice thing is that the deleting of the active listening record on one client, can perfectly be done by an other client!

More in detail…

To keep track the user we create a unique session ID at the startup of the database. This can be the users’ login name, IP address, … whatever you want. The only requirement is that this session ID is unique, so you know who you are talking to. The login name is maybe not the most ideal thing to use because a user can be logged in on different platforms at the same time with the same user name ( for example in FM Pro and WebDirect at the same time ). A serial key works perfect. We store this ID in a global field during the session.
Then, a record in the listening table is created. The record also stores the unique session ID. This record must be loaded in the layout with the onRecordLoad script trigger enabled. This window can then perfectly be hidden in the background.
When someone deletes that records, the onRecordLoad script trigger is fired and a dispatching script can check what to do…

The sky is the limit

Because a FileMaker script is triggered we can do the impossible with scripts… Delete records, make records, show dialogs, perform AppleScripts, … anything you can dream of.

In my opinion the most useful feature of this technique will be setting up a client robot, who can perform scripts on-click. Making pdf’s, load testing, connections with 32bit ODBC drivers, …
I see this technique as a ‘Perform script on server’ variant for the client. So everything that is not possible on the server, we can now perform on a robot client, on-click.

 

Demo File

In the example, there are two functions implemented. The first one is a simple messenger system. Here you can just write simple messages to another client. A custom dialog is shown on the other client.

The second one is a printscreen capture, where you can take a print screen of an other clients computer. ( because it uses an applescript, this only works on the Mac ).

Click here to download the file

 

Update

This technique has been adopted and highlighted by other. We want to thank especially Seedcode for using it in their ‘PDF Robot‘.

Richard Carlton (RCC Consulting) did an amazing video on this. Big shout out to you Richard!

We crafter a demo for creating a PDF in WebDirect on modularfileMaker.org.

28 sept. 2015: I found out that Uli and I discovered the technique independently. See the discussion in de FileMaker community forum. Respect Uli!

ClickWorks
support@flux.be