Frequently Asked Questions about  EventScript ( plug-in for FileMaker )

 


Last Updated: July 13, 2006

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

What is the master password for the example file named EventScript_Samples.fp7 ?

 

 

The master account that unlocks everything in the main sample file is admin and there's no password(leave empty).

To switch between users, there are also two buttons placed on the top of every demo layouts. Click on the " Re-Login Admin " button to gain access to the whole database structure and click on the "Re-Login Events" button to try out the trigger examples as a real user.

 

  top

 

 

What is the general syntax for EventScript invocations ?

 

 

The triggering function accept 2 to 3 parameters :

S4HU_EventScript( Get(FileName) ; ScriptName ; [OptionalScriptParameters] )

The 1st parameter is required and it is the name of the file where your target-script is placed. It can be hardcoded as text within quotes(""), it can be dynamically assign by using the content of a textual field or it can be relative to the current name of your database by using the "Get(Filename)" FileMaker built-in function.


The 2nd parameter is also required and it is the name of the script you want to trigger from your calculation. It can be hardcoded as text within quotes("") or it can be dynamically assign by using the content of a textual field.

The 3rd parameter is the optional script parameters that you can pass to the triggered script itself. These can be hardcoded as text within quotes("") or it can be dynamically assign by using the content of a textual field(s).
If you want to pass more than one parameter to your target-script, then use the 'CRLF character' to separate each script parameters (this character is symbolized in the calculation boxes, as a kind of reversed 'P' character).  Here's an example for passing multiple hardcoded script parameters: "parameter1¶parameter2¶parameter3"
If you have no parameter to pass to the target script, then simply enter "" (that's double-quote) as the 3rd parameter.

EventScript will return an error code if the script referenced by the first and/or the second parameter are wrong.  This error code will be represented by a question mark (?) meaning that the target-script cannot be found, and therefore cannot be launched.  As soon you fixed the "naming problem", then the script should be triggered at the moment your calculation will be eveluated by FileMaker.

There is no validation on the 3rd Eventscript parameter but it has to be a textual content.

 

  top

 

 

I'm looking for a simple way to trigger before update events?

 

 

Note: This is a more complex one, so if you are beginning with script triggers, it is maybe a good idea to try an "after update" event first...  Also, make sure that a simple FileMaker button placed on your field on the layout is not doing the same job correctly...

 

Here are some basic tips about implementing before-update triggers on a text, a number, a date, a time, a timestamp or a container field!

So the idea is to monitor the event when a user is placing his computer's cursor into a specific field, then trigger a script before the field can actually be entered.  This is the "before-update" event.

First, create a new privilege set as FileMaker doesn't allow modifications to the built-in sets([Full Access], [Data Entry Only] and [Read-only Access]).  Actually, we need to customize something in the privilege set for the before-update trigger to happen...

To accomplish this, there is many mouse clicks but it is not that complicated.  Go on the 'File' menu then 'Define...', 'Accounts & Privileges', then go on the tab named 'Privilege sets' :

 

Select the privileges set called "Events" or create a new one if it doesn't exist yet.  The permissions you are going to configure will apply to all future users of this 'group'.

Once in the 'Edit Privilege Set' dialog, go under the permissions in the 'Data Access and Design' section and choose under the 'Records' dropdown the item called 'Custom Privileges' :

Then choose the correct security intersection where the X axis is the user's action and the Y axis is the table you want to monitor.

For the desired action, go under the corresponding 'limited...' item under the record-editing permission.  And you will be prompt with the familiar calculation dialog box.  This is where you can enter your condition and the trigger statements.

It is a good idea to place an IF or Case statement if you want your before-update script to be triggered only when users enter specific fields.

Example calculation :

If ( Get ( ActiveFieldName ) = "YourInputField" ;

// Then
1 & S4HU_EventScript ( Get(FileName) ; "YourBeforeUpdateScript" ; "" );

// Else
1)

 

See the calculation below :

The '1' are required. they are telling FM that the validation rules are ok. We are only using the pre-validation event to place the EventScript call, we aren't really validating data at this stage.

Finally, you should assign which users will have this new privileges set.  This is a 'role-based' schema so you can, for example create a new 'Events' privileges set and assign all the account/persons that should have this role in your application (clerks, sale reps, etc.)  The users who belong to this 'Events' privileges set will have the script triggers while other users who belong to other privileges set won't necessary get all these triggers.

 

TEST DRIVE !

When a user of this privilege set place his cursor into the field called "YourInputField", by using the tab key or directly when entering with his mouse...

then the target script named "YourBeforeUpdateScript" will be triggered each time :

 

(The calculation proposed in our example file is checking first for the correct launching of the before-update script. For purposes of this tutorial, the calculation here is a lot simpler)

Please note that a trigger built inside the security features will work on every layouts of your FileMaker file.  This is an advantage over individual buttons.

 

  top

 

 

I'm looking for a simple way to trigger after update events?   (using the auto-enter option)

 

 

Here are some basic tips about implementing after-update triggers on a text, a number, a date, a time, a timestamp or a container field!

The idea is to monitor the event when a user is placing his cursor outside a specific field, then trigger a script if the content of this field has been edited.  This is the "after-update" event.

The simplest way to place an "after update" event in FileMaker is to go under the "Define Database" menu, choose your table, then in the field on which you want to have an after update trigger, set an "Auto-Enter" option with "Calculated Value".

Example calculation :

CostPrice_NFX & S4HU_EventScript( Get(Filename); "TheExactNameOfYourTargetScript"; "")


See the picture below :



The "CostPrice_NFX" part in this calc is required in "Auto-enter" option because FileMaker is waiting to make an auto-enter operation in the watched field as soon the user exits this field. So you need to tell to FM to place the actual contents of the field( itself ) and then also launch the script at the same time . Think of this auto-enter functionality as a kind of built-in "Set Field" script step.

Make sure you uncheck the "Do not replace existing value of field (if any)" checkbox just under the "Calculated value" option and give it a test. Your script will be launched every time a user 'updates' the content of this field. If you don't place any additional conditions in the privileges set, all users of your solution will have the same "trigger behavior".

TEST DRIVE !

When a user will exit the field called "CostPrice_NFX", if the content has been edited...

then the target script "TheExactNameOfYourTargetScript" will be triggered each time :

(The calculation proposed in our example file is checking first for the active privilege set AND for the active field name. For purposes of this tutorial, the calculation here is a lot simpler)

Please note that a trigger built inside a field will work on every layouts of your FileMaker file.  This is an advantage over individual buttons because the 'button' is actually inside the field itself.

 

  top

 

 

I'm looking for a simple way to trigger after update events? (using the validation option)

 


Another good solution is to use the validation rules for triggering a script for your watched-field. The "Validated by calculation" options are much more persistent and it won't exit until the validation rules are totally met.  It will trigger the script when exiting the validated field even if the user is trying to browse to another record, table or layout.  Closing the file and/or the FileMaker application can also be forbidden.

The simplest way to place a validation "after update" event in FileMaker is to go under the "Define Database" menu, choose your table, then in the field on which you want to have an after update trigger, set a "Validation" option with "Validated by calculation ".

Here's an example of a simple validation calculation :

1 & S4HU_EventScript ( Get ( FileName ) ; "TheExactNameOfYourTargetScript" ; "")

See the picture below :


The 1 is required.
It tells to FM that the validation rules are ok. We are only using the validation event to place the EventScript call, we aren't really validating data at this stage.

 

TEST DRIVE !

When a user exits the field called "InvoiceLogo_RVX", if the content has been edited...

then the target script "TheExactNameOfYourTargetScript" will be triggered each time :

 

(The calculation proposed in our example file is checking first for an empty value in this container field. For purposes of this tutorial, the calculation here is a lot simpler)

Please note that a trigger built inside a field will work on every layout of your FileMaker file.  This is an advantage over individual buttons because the 'button' is actually inside the field itself.

 

  top

 

 

What are the proposed steps to implement event triggers in my solution ?

 

 

When implementing complex EventScript triggers , you will usually have to go through these 4 steps:


1. Choose the moment where you want your script to be triggered.
2. Go to the corresponding calculation box for this moment and place the EventScript invocation.
3. Optionally, if the calculation is re-calculated too often and/or if you want to fine-tune the 'event', then you can add some additional IF or CASE statements to launch the script only under particular conditions.
4. Optionally, you can add in the event some other 'parallel processes'. For example to manage at the same time a console-module as proposed in our demonstration file.

 

  top

 

 

What is the differences between EventScript versions 1.0 and 1.1 ?

 


EventScript 1.1 is basically the same as EventScript 1.0, but with the following improvements:

The "S4HU_VersionEventScript" function now returns the current plug-in version AND the operating system;
for example, "S4HU_EventScript 1.1 Donationware (Win32)".

The "S4HU_EventScript" function is friendlier by providing default parameters:
S4HU_EventScript( Get(FileName) ; ScriptName ; [OptionalScriptParameters] )

 

  top

 

 

Is it possible to deploy EventScript on FileMaker workstations by using the FMI's auto-update plug-in ?

 


Of course it is possible.  And relatively easy to distribute EventScript to all FMP workstations by using the plug-in 'Auto-Update' from FileMaker Incorporated.

 

We are suggesting you these interesting links to learn how to accomplish this :

http://filemaker.com/downloads/pdf/fms7_auto_update.pdf

http://clevelandconsulting.com/support/viewtopic.php?p=959

  top

 

 

Is EventScript working in the separation model ?

 


Sure EventScript can work inside a multi-files solution.  Depending on the relationships you have between your files, a requirement to trigger scripts which are physically placed in another Filemaker file, will be to open this distant file before using these triggers.

So make sure you are running an opening (startup) script to open your target file(s) and the EventScript triggers will work perfectly, even if the trigger is inside the "file 1" and the script to run is into the "file 2".  The distant files can be opened in hidden mode.

About the plug-in's call, do not forget the 1st parameter is the name of the file where the script to run is placed. An example for an auto-enter option trigger will be :

FieldInFile1_TFX & S4HU_EventScript( "File2" ; "DistantScriptToRun" ; "" )

 

 

  top

 

 

Will EventScript be released as Universal Binaries ?

 


July 13rd, 2006: An UB version of EventScript was announced on july the 11th.  The new version 1.1 is compatible with both PowerPC and Intel-based Mac computers.  It can be used with FileMaker 7, 8 and 8.5 and it is available for download here.

 

  top