[Updated March 22, 2016]
After working on a solution that eventually became FileMaker WebDirect-ified, it became quite evident that we needed to find a way to do reporting from web-based clients. As most of you are probably already aware, the very useful “Save as PDF” script step that FileMaker Pro provides is not available to clients accessing your system via Web Direct. There are a number of solutions to this problem already, but I had problems getting some of them to work, and others didn’t quite fit the bill.
As a result of this dilemma, I decided to roll on my own - I ended up creating a module that is relatively easy to implement, flexible, and even allows you to reuse your existing reporting scripts should you find yourself in a situation similar to mine.
What This Module Is
This module is essentially a framework for telling a FileMaker Web Direct session to hand off a script to a FileMaker Robot machine. You might be wondering what I mean by a FileMaker Robot machine… Good question! When I refer to a FileMaker Robot machine, I’m essentially talking about an installation of FileMaker Pro that sits idly by with no users working on it. When a FileMaker Robot machine is configured properly with this module, it will essentially just wait for a FileMaker Web Direct user to ask it to run a script for them. This is particularly handy in cases where FileMaker Pro is capable of doing things that FileMaker Web Direct is unable to.
How to Install this Module
- Copy tables
- Copy custom functions
- Clean up the layouts that are automatically created (delete everything but the "Container" field, make the layout blend in with your system, and make that container field take up the majority of the screen)
- Copy the main script folder (Perform Script On Robot) from sample solution into yours
- Create a new account in your system to be used by the robot. The default account name is "Robot", though this can be changed in the config file
- Modify the "PSOR Config" script (Optional)
- Attach the "PSOR On Record Load - Look For New Jobs" script as an On Record Load script trigger on the "PSOR_ActiveJobs" layout
- Attach the "PSOR On First Window Open" and "PSOR On Last Window Close" as script triggers on the file
- Login to the system with your “Robot” account from FileMaker Pro on the robot machine
Once installed, the solution can be very simple to implement. To understand how to implement it, you should keep in mind that the goal of this module was twofold; to be able to create PDF’s seemingly from WebDirect and to be able to reuse the same scripts that create those PDF’s from FileMaker Pro clients. After all, who likes rewriting code to do the same thing multiple times?
Keeping that in mind, with just a couple of simple additions, every one of your scripts that generates a PDF file can probably be modified so that it can be run from your Robot machine as well.
- Each one of those scripts will need a section at the top that determines if the script should continue running, or be handed off to the robot to continue (see sample file for details on this)
#IF THIS IS BEING RUN FROM WEB-DIRECT, HAVE THE ROBOT MACHINE RUN THIS SCRIPT INSTEAD
IF [ $$IAMWEBDIRECT ]
PERFORM SCRIPT [ “PSOR - ASK ROBOT TO RUN THIS” ;
PARAMETER: INFOFORROBOT__CF ( )GO
//& NAMEVALUEPAIR_BROWSE__CF ( _NAME ; _VALUE )
//& NAMEVALUEPAIR_FIND__CF ( _NAME ; _VALUE ) ]
#ROBOT MACHINE RUNS EVERYTHING UNDER THIS LINE, AND SHOULD EXIT WITH THE PATH TO THE PDF THAT WAS CREATED
- Each one of those scripts should create a PDF (or some kind of file), and exit the script with a result representing the path to that newly created file
If everything went smoothly, then anytime you try to run one of your newly modified scripts from WebDirect, the handoff should take place, and the user will be left on a screen that displays the PDF.
If you're interested in the actual solution, you can download it here.
And if you enjoy our FileMaker Blogs, be sure to subscribe to our Core FileMaker Newsletter!
Have any questions or comments about this solution? Have anything you would like to add or change? Feel free to let us know in our comments section below.
And as always, thanks for reading!