Script

What is a script in FileMaker?

With a Script any processes in a FileMaker database can be executed automatically. FileMaker supports the creation of any number of scripts per database, which in turn (theoretically) can contain any number of commands. With script parameters any parameters can be passed between scripts.

Add a new script until FileMaker 13

Scripts can be added and edited in FileMaker up to version 13 using the menu command [Scripts > Manage Scripts].

Script selection window in script editor

To add a new script in FileMaker up to version 13, click the [New] button in the Script Editor. By clicking the arrow icon, you can optionally add an empty script, a default script, a script folder, or a separator.

Script folders can be used to arrange scripts hierarchically in the script editor.

With a standard script, the following commands are automatically inserted into the new script:

Enable Browse Mode []
Go to Layout ["Current Layout" (Current Table)]
Show all records

Add a new script from FileMaker 14

Scripts can be added and edited in FileMaker 14 and later using the menu command [Scripts > script workspace].

Script workspace as of FileMaker 14

To add a new script in FileMaker 14 and later, click the [+] button in the script workspace, and a new script is immediately created that you can name as you wish. A script folder and a separator line can now be created by clicking the corresponding icons in the [Scripts] bar below the [+] icon. Script folders can be used to arrange scripts hierarchically in the script editor.

Script parameters and global variables

For many years, FileMaker has supported adding script parameters to scripts to exchange data between scripts. With each script call a parameter can be added, which can be set within the script with the function

Get ( ScriptParameter )

can be read out again. In principle, data can also be written into a global variable to be read out by all scripts within the same file. Script parameters, on the other hand, can also be passed across files.

Pass multiple script parameters

Although a script parameter in FileMaker consists of only one line, several parameters can be transferred at the same time with appropriate separators. The apostrophe | can be used as a separator, which normally does not appear in other data.

Custom Function “StringTeilen”

With a small custom function the separation of a string can be simplified. You can integrate the following function into your FileMaker solution using FileMaker Pro Advanced to split a string with separators into its individual entries:

>strong>StringParts ( String; Number ) =
cases(number = 1;
 characterLeft ( String; (Position ( String; "|"; 1; 1))-1);
center of character ( String; (Position ( String; "|"; 1; Number-1))+1;
(Position ( String; "|"; 1; Number)) - ((Position ( String; "|"; 1; Number-1))+1))
)

example

$string = "House|Boot|Auto|"
StringParts ($string; 1) = "House"
StringParts ($string; 2) = "Boot"
StringParts ($string; 3) = "Auto"

Script-Trigger

FileMaker allows many different script triggers on different objects to execute scripts on specific user interactions or on a scheduled basis. For example, you can have scripts run automatically when a particular layout is called, when a special key is held down during a mouse click, when a field value is changed, and for an almost infinite number of other actions.

Related entries

Diesen Beitrag bewerten:

About Author

Markus Schall
Development of FileMaker databases since 1994, modification and extension of FileMaker solutions, conversion of FileMaker databases from .fm, .fp3, .fp5 (FileMaker 2-6) or .fp7 (FileMaker 7-11) to .fmp12 (FileMaker 12-17), interfaces to third-party systems such as online shops, CMS or other databases. Development of individual FileMaker database systems based on the gFM business framework with personal advice from Oldenburg. Operator of the online specialist portal goFileMaker.de, developer of the CRM and merchandise management system gFM-Business. Member of FileMaker Business Alliance, FileMaker Developers Subscription and FMM Expert. Winner of an FMM Award 2011, awarded by the FileMaker Magazine.