MonkeybreadSoftware Posted December 13, 2023 Posted December 13, 2023 We recently had a client with a problem exporting data in a server side script. Since server scripts run blindly and we can't debug them, we check FileMaker's logs, enable script error logging and add calls for MBS("Trace") and MBS("Log"; ...) calls to log data to the log file from our MBS FileMaker Plugin. We quickly noticed that the Export Records script step failed with error 3, which is command unavailable. After that I quickly looked though FileMaker's documentation and identified functions with limited Data API support: Function Data API Server Close Data File No Yes Configure Machine Learning Model No Partial Copy All Records/Requests No Yes Copy Record/Request No Yes Create Data File No Yes Exit Application No Yes Export Records No Partial Get Data File Position No Yes Get File Exists No Yes Get File Size No Yes Import Records No Partial OnFirstWindowOpen No Yes OnLastWindowClose Partial Yes Open Data File No Yes Print Setup No Partial Read from Data File No Yes Save Records as PDF Yes Partial Set Data File Position No Yes Show/Hide Toolbars No Yes Write to Data File No Yes As you see, there are plenty of functions, which are not supported for Data API, but are for normal server scripting. This table is based on Claris FileMaker 20.3 documentation, so it may be different for your version of FileMaker Server. If you like to use a function like Export Records in your script, you may need to use Perform Script on Server to run the script in the server scripting process. For our client, it looks like this: They use FM Better Forms, where the user clicks a button. This button then performs the script in Data API engine. Since Export Records script step is not available, we have to trigger another script using Perform Script on Server. This script then goes to the right layout and record ID (passed as script parameter). Then the script does the Export script step and signals back the result. Over time we hope Claris can support more script steps for Data API as the code should be there. MBS FileMaker Plugin can be used on all three engines on FileMaker Server: Server Scripting, Data API and Web Direct.
Recommended Posts