Scheduling administrative tasks : Running server-side scripts : Running FileMaker scripts
 
Running FileMaker scripts
Note  The following information is for server administrators and group administrators.
FileMaker Server can run FileMaker scripts that are created in hosted databases. You create a schedule to run a FileMaker Script scheduled task, specify the database and the FileMaker account to use to run the script, choose a script created in the database, and when to run the script. FileMaker scripts that run on FileMaker Server can do simple or complex tasks such as:
perform a field recalculation across all records
process and archive new transactions nightly
remove duplicate records before a scheduled backup
You use the Manage Scripts feature (formerly ScriptMaker) in FileMaker Pro to build scripts by selecting from a list of FileMaker Pro commands, called script steps, and specifying options. To run a FileMaker script on FileMaker Server:
The script should include script steps that are supported in a FileMaker Server schedule.
The script must be defined in a database file that is hosted on FileMaker Server. See Hosting databases.
For information about creating FileMaker scripts with script steps that are supported in a FileMaker Server schedule, see FileMaker Pro Help.
You can also create a Script Sequence scheduled task that runs optional pre-processing and post-processing system-level scripts before and after a FileMaker script. See Creating Script Sequence tasks.
Notes
You can select Abort schedule if time limit reached or server stopped in the Schedule assistant to abort the FileMaker script schedule if the script takes longer to run than the specified time limit, or if the Database Server stops. If you do not select Abort schedule if time limit reached or server stopped, and a FileMaker script hangs, you can stop the script on the Activity > Clients tab. (See Event log.) You can stop the script on the Activity > Clients tab.
If scripts contain steps that aren’t supported in FileMaker WebDirect solutions, Custom Web Publishing, or in a FileMaker Server scheduled script, use the Allow User Abort script step to determine how subsequent steps are handled.
If the Allow User Abort script step option is enabled (On), unsupported script steps will stop the script from continuing.
If the Allow User Abort script step option is disabled (Off), unsupported script steps are skipped over and the script continues to execute.
If this script step is not included, scripts are executed as if the feature is enabled, so unsupported script steps will stop scripts.
Some script steps have options that are skipped, such as an option to show a dialog box. The Event.log file contains detailed information about errors or script steps that are skipped when FileMaker Server runs FileMaker scripts. See Viewing log file entries.
Server-side FileMaker scripts run in separate sessions in the FileMaker Script Engine, behaving like they do for Custom Web Publishing. Each session has its own copy of global fields and variables. Calculation functions return the same values as when scripts run under Custom Web Publishing, with the following exceptions:
Get(AccountName) initially returns the account name that the script was run under (specified in the Schedule assistant when the schedule is created).
Get(UserName) returns the schedule name.
Get(ApplicationVersion) returns the Database Server version string.
Functions related to hardware, such as Get(SystemIPAddress), return information from the Database Server.
Whenever a session starts for a server-side FileMaker script, a unique temporary subfolder is created for that session in the temp folder on the FileMaker Server computer. The temporary subfolder name begins with the letter “S”, followed by a number representing the session. You can use the Get(TemporaryPath) function to return the path to the temporary subfolder. When the session is terminated, the temporary subfolder and any files placed in it are deleted.
When running on FileMaker Server, the Get(DocumentsPath) function returns the path to the Documents folder, which is in the same folder as the server’s Backups, Databases, and Scripts folder. You can use the Documents folder as a shared location for passing import and export files between pre-processing scripts, FileMaker scripts, and post-processing scripts in Script Sequence scheduled tasks.
Use the Get(DocumentsPathListing) function with the Import Records and Export Records script steps to determine if a file exists before using the Open File script step to open the file, and to ensure that multiple scripts can safely read and write to the same FileMaker Pro database.
FileMaker Server evaluates relative file paths in import and export script steps in relation to the Get(TemporaryPath) unique subfolder. Script steps that use relative paths containing “..” return an access error when performed. Script steps can use absolute paths if they point to the Documents folder or any of its subdirectories. That is, the beginning of the absolute path must be the same as the path returned by the Get(DocumentsPath) function. For example, any OS X path that starts with /Library/FileMaker Server/Data/Documents is acceptable.
If you run a FileMaker script that uses the import ODBC script with a third-party ODBC driver, you need to use the 64-bit version of the ODBC driver. For a script that runs on the server, only 64-bit ODBC drivers are supported.
Related topics 
Creating a schedule
Running server-side scripts
Scheduling administrative tasks