Skip links

Run FileMaker Server Script from FileMaker Runtime.

Rent ERP software as a cloud server package

Run scripts on FileMaker Server from RuntimeWith FileMaker, you can easily start scripts of remote FileMaker databases and pass corresponding parameters if required. Simply set up the remote file as an external data source and start the Script the distant Database via the Script Editor. The situation is different with a script created in FileMaker Pro Advanced. Runtime. Since runtime solutions are not network-compatible, it is not possible to use on-board resources to create a script for a FileMaker Server database, let alone pass the associated parameters. With the MBS plugin from Monkeybread Software, however, this hurdle can be easily overcome. If the database on the FileMaker server has also been released for PHP, a script of a database stored in the Network or Internet shared FileMaker database from a runtime solution - including parameter transfer. In this article, we show how this can work.

Prerequisite: FileMaker Server and MBS plug-in

MBS FileMaker pluginSince a FileMaker Runtime solution does not provide the ability to contact remote databases, the script call cannot be made in the traditional way. In this article we use the PHP capabilities of a FileMaker Server in conjunction with CURL from the MBS plugin. For this reason, the use of a FileMaker Server and the MBS plugin is mandatory for the solution presented in this article. The MBS FileMaker Plugin is available from Monkeybread Software for Mac OS X and Windows at prices starting from 99 Euro plus 19% VAT. In version 5.0, available today, the MBS FileMaker Plugin now offers over 3,000 new functions for use in FileMaker databases. In addition to the CURL functions described here, the plugin opens up many other possibilities such as the internal processing of PDF documents, control of scanners and other hardware, TAPI functions and barcodes, SQL-connections, internal graphics editing, file manipulation and many, many other features, as well as some conveniences in FileMaker itself, such as syntax coloring.

FileMaker and Indians

Like OS X Server, FileMaker also uses an Apache web server to provide data for the PHP API or for web publishing. As soon as FileMaker Server has been installed, the Apache web server is usually also available, which FileMaker Server requires for the web release of databases. To call a script in a database hosted by FileMaker Server, we also need the Apache web server installed with FileMaker Server. The underlying principle is simple: we create a PHP file to call a script, which can be called directly from a FileMaker runtime solution via URL using the MBS plugin. The PHP file reads the name of the script and, if necessary, a parameter and passes both details to the corresponding database provided by the FileMaker server.

Create PHP file for data transfer

So first we need to create a PHP file to realize the data transfer from the FileMaker Runtime solution to the FileMaker database shared by the FileMaker Server. The Apache web server of the FileMaker Server stores such files in the directory

Macintosh HD/Library/FileMaker Server/HTTPServer/htdocs

A PHP file must now be created in this directory, which contains the following source code, for example:

<html>
<head>
    Sample file
</head>
<body>
<p>
     <?php
     error_reporting (E_ALL);
     require_once ('filemaker.php');
     $v = $_POST["parameter"];
     $connection =& new FileMaker();
     $connection->setProperty('database', 'RemovedFile');
     $connection->setProperty('hostspec', 'Server address');
     $connection->setProperty('username', 'Username');
     $connection->setProperty('password', 'Password');
     $cmd = $connection->NewPerformScriptCommand('RemovedFile', 'Scriptname', $v);
     $result = $cmd->execute();
     if (FileMaker::isError($result))
     {
          echo $result->message;
     }
     echo 'Script executed';
     ?>
     </p>
</body>
</html>

The PHP file takes over in the Variable $v takes the script parameter from the FileMaker Runtime solution and passes it in the line "$cmd = $connection->NewPerformScriptCommand('RemoteFile', 'ScriptName', $v);" to the remote FileMaker database shared by the FileMaker Server.

Calling the PHP file from the FileMaker Runtime solution

To be able to execute the PHP file from the FileMaker Runtime solution by passing a parameter, we use the CURL functions of the MBS plugin. Make sure that the MBS plugin has been successfully integrated into the runtime solution. The following script commands are required to execute the created PHP file with parameter passing:

Set variable [$curl; Value:MBS("CURL.New")]
Set variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "http://www.IhrFileMakerServer.de)]
Set variable [$result; value:MBS("CURL.FormAddKeyValue"; $curl; "parameter"; yourScriptParameter)]
Set variable [$result; Value:MBS("CURL.FormFinish"; $curl; $input)]
Set variable [$result; Value:MBS("CURL.Perform"; $curl)]
Set variable [$result; value:MBS("CURL.Cleanup"; $curl)]

The above commands call the PHP file stored on your FileMaker server and pass a parameter. However, passing parameters is a one-way street: With this method, parameters can only be passed from FileMaker Runtime to the server via CURL - this is not easily possible from the server to FileMaker Runtime.

Leave a comment

Share this page:

ERP software as flexible as your company.
We will be happy to advise you.

Customizable ERP software for Mac, Windows and iOS.

You are here: Run FileMaker Server Script from FileMaker Runtime.