fm_perform_script


mixed fm_perform_script ( string $file_name, string $script_name [, string $script_parameter [, int $control ]] )


 

Description


Allows you to trigger FileMaker scripts from within your PHP code.

Notes:

  1. The PHP code must complete execution before any scripts will be triggered.
  2. If you're calling the PHP code from a script, that script must complete before any scripts will be triggered.
  3. If you make multiple calls to fm_perform_script, the scripts will be queued and performed in the order that you called them.

 

Parameters


file_name (required)
The name of the file that contains the script to be performed. Can be left empty to default to the current file.

script_name (required)
The name of the script to perform.

script_parameter (optional)
The script parameter to be sent to the script. Note that SmartPill 3 supports sending containers in the script parameter.

control (optional)
Tells FileMaker what to do if another script is running. Use one of the following control values: 0 = halt, 1 = exit, 2 = resume, 3 = pause (default). Any value other than 0, 1, 2 or 3 will be ignored and the default value 3 will be used.

 

Return


Returns 0 when the script is successfully triggered. Returns NULL when script triggering is disabled. If script triggering is disabled, fm_get_last_error will return 901 Script triggering is disabled.


Errors


100 File is missing (check the file_name parameter)
104 Script is missing (check the script_name parameter)
901 Script triggering is disabled (use fm_script_control to enable script triggering)

Example 1 - Perform script with script parameter
fm_perform_script('Testbed', 'Test_Script', 'Hello');
/*
Returns: 0
*/
Example 2 - Perform script with file_name parameter left empty
fm_perform_script('', 'Test_Script', 'Hello');
/*
Notice that the file_name parameter is empty, this is okay, the current file name will be used
Returns: 0
*/
Example 3 - Perform script with container script parameter
// Todo - https://scodigo.atlassian.net/browse/SGOSP-47

Change Log

VersionDescription
3.0.0Containers can now be sent in the script parameter.