Appended PDFs in FileMaker Go (FM16)

With the release of FileMaker 16, we have seen a great number of new and improved script steps. FileMaker 16 extended the capability of the Save as PDF script step, now allowing it to work partially with WebDirect, FileMaker Go, and Server, however there are a few things of note.

As documented by FileMaker, the limitations are as follows.

A very useful feature, append to PDF allows you to tie together multiple reports into a single document and so not being able to use it in FM Go can pose a bit of a problem. Using some of the new steps allowed in FileMaker 16, I came up with a work-around.

My first thought was to insert from URL into a variable (a new feature added in FMP v16). However after testing this, I discovered an issue with inserting binary files into variables in the  Insert from URL script step in v16.

My solution is to use one global container field that will hold the PDF. Then pass the container field as a base64 encoded variable from the server side script to the script called from FileMaker Go. This solution relies on the Perform Script on Server (PSOS) script step, so it can only be utilized for hosted databases.

Things to look out for when using PSOS:

PSOS is great for a lot of tasks. Running resource heavy tasks on the server can improve speed and performance from the client’s perspective. However it is worth mentioning a few of the common errors and things to prepare for when using PSOS.

  • First, of course, you must be using FileMaker Server and your file must be hosted. If you are trying to use PSOS on a local file you will get error code 3.
  • Occasionally we have seen instances where the FileMaker Scripting Engine (FMSE) will crash. When this happens, you will see ‘scripts in process’ in the Server Log. You will also get an error when using PSOS. You can restart the FMSE from the command line, or by restarting the server.
  • The last issue has to do with the maximum capacity of the host. There is a setting in the FMS Admin tool which allows you to specify the maximum number of simultaneous script sessions. Each time the PSOS script is run, it begins a new session. If you set “Wait For Completion” to OFF  in the PSOS script step, this leaves you open to creating too many simultaneous connections. If you need to wait to return a result or wish to capture an error turn it ON.
  • Debugging can be a bit of a pain with PSOS, but I find using the FMS Log Viewer can help. When looking at the log viewer, if there is an error in the script you will see something like the following. It will list the error code (1631) and the script line (29) so it’s not too difficult to see where the scripting errors are occurring.




The Demo File and How it Works

In my demo file I have two separate reports that I am using to generate a single PDF. There are two scripts that are making this happen.

iOS_Save_Appended_PDF is the script tied to the button on the landing page that calls the PSOS script and checks for errors. If the PSOS script runs successfully, it grabs the  Base64 encoded PDF as a script result and then inserts it into the global container field, and then exports it, which will actually open the saved PDF in FileMaker Go.

PSOS_Append_PDFs [$PDF] is the second script, which is run on the server and is called from the first script. This script generates and appends the reports. In my demo I’ve left out steps to bring up the exact reports. Because this script is getting run on the server, the context for the report will need to be set here (or in a subscript) called by this script. You will need to pass parameters in order for the script to perform a find on the set or records you wish to include in your report. After the PDF is generated, it is inserted into the global container field, then a Base64 encoded variable is set to the script result.

~ Kate Waldhauser

Leave a Reply

Your email address will not be published. Required fields are marked *