FileMaker Server does some funny things when you create a stored calculation that uses a plug-in. In fact, odds are you received everyone’s favorite invalid character, the `?`. This article explains why this occurs and gives some solutions for this rather pesky problem.
Umm… I Think Something’s Broken
Let’s say you just bought our new barcode plug-in (shameless plug I know… but I needed an example) and you are just chomping at the bit to go home and make a bunch of barcodes to help organize your vintage Transformer collection. So you fire up your computer, log on to your FileMaker Server, open up the Transformer database and define a new field, aptly named `Barcode`. You set the field up as a stored calculation that evaluates the plug-in function `sfrbc_barcode( Transformer::ID )`, then sit back and relax while your computer chugs along and processes your 294,131 records. When it’s all finished you throw your new `Barcode` field onto the layout and expecting to see your lovely new barcodes but instead you see the dreaded `?`. The first thing you do now is probably call us up and yell at us for providing you with a piece of crap plug-in that doesn’t work. As much as we wish we could make this work auto-magically… alas, we cannot. And here’s why.
Typically, when you create a record with a stored calculation the calculation result is evaluated on your, the client, machine. This however is not the case when you are defining fields. During field definition, FileMaker Server actually handles all the heavy lifting and creates those barcodes for the 294,131 original works of art you have hiding in show boxes. Unfortunately, since you probably don’t have the plug-in installed on FileMaker Server this is a problem.
Using a Replace
The quick and dirty solution to this problem is to use a replace. I know… replaces don’t work on calculations, but we aren’t going to use a replace in the calculation field itself. We are going to replace the field it *depends* on. In our example from above, we defined the `Barcode` field as `sfrbc_barcode( Transformer::ID )`. In this calculation, the *dependent field* is `Transformer::ID`, so we are going to replace that field with itself. To accomplish this just follow these easy steps
Records -> Show All Recordsto ensure that you update all your records
- Click in the `Transformer::ID` field.
- Open the
Records -> Replace Field Contentsdialog box
- Click on `Replace with calculated result:` like so:
- In the
Specify Calculationbox that pops up, select the name of the field you would like to use in the replace, in our case
- Click `OK` then Click `Replace`
You should now be ripping through your records and replacing `Transformer::ID` with itself.
>Note: Since your are replacing a field with itself, you aren’t blowing away any of your data or messing up any of your relationships. You are simply re-triggering the calculation in the `Barcode` field. You *will* change any Modification times, dates, or timestamps in your record, though.
Once this process is finished, you will notice that the barcodes that you paid your hard earned money for are now present. The whole premise behind this solution is that when you use the replace command, stored calculations all evaluate on the client, your machine where the plug-in is installed, rather then on FileMaker Server. This allows you to get away without having to actually install the plug-in on your FileMaker Server, but quite frankly it isn’t quite ideal.
Install/Enable Plug-in on FileMaker Server 9
This is definitely the preferred solution. You’ll never have to worry about doing any hokey replaces and you’ll be able to leverage the greater (unless your sever is pokey) processing power of your FileMaker Server machine. All we have to do is install the plug-in on the server, then enable FileMaker Server 9 to use the plug-in.
>Note: This approach works equally well on FileMaker Server 7+. This particular article is written with FileMaker Server 9 in mind, because — quite frankly — the interface is now the same on a mac and pc so it’s easier to write up. You can achieve the same results with FileMaker Server 7+ we just don’t have the exact steps handy.
Installing a plug-in on FileMaker Server 9
Installing the plug-in is actually quite easy. All you have to do is take a copy of your plug-in and place it in the appropriate folder on your server.
For a Mac:
/Library/FileMaker Server/Database Server/Extensions
For a PC
C:/Program Files/FileMaker/FileMaker Server/Database Server/Extensions
You’ve now successfully installed your first plug-in on FileMaker Server. Now, all we need to do is make sure that FileMaker Server knows that it can use the plug-in, and for that we need the trusty old FileMaker Server 9 web interface.
>Note: The Mac folder path is pretty much always the same. The PC directory can change depending on where you actually installed FileMaker Server but the one I provided is the default install. If you did your own custom install on a PC, just find the `/FileMaker Server/Database Server/Extension` folder and drag a copy of your plug-in into it.
Enabling a plug-in on FileMaker Server 9
Now that the plug-in is installed we just have to tell FileMaker Server 9 that it is OK to use the plug-in. First things first, we have to get FileMaker Server to recognize the plug-in and to do that you have to shut down the server and start it back up.
1. Fire up your admin interface and you should see these two buttons above in the upper left hand corner of your screen
1. Hit the Red button to stop server
1. Type a message to send to all connected clients and hit OK
1. Once all the files have closed, hit the Green button to start the server back up
With the server rebooted, we will be able to enable the plug-in. Select
Configuration -> Database Server in left side of your admin interface like so:
A new set of tabs will appear that look something like this:
Just click the `Server Plug-Ins` tab and you’ll see a list of the plug-ins installed on your Filemaker Server. Check the `Enable FileMaker Server to use plug-ins` box and check the plug-in(s) which you would like FileMaker Server to use and you’re finished. FileMaker Server 9 will now be able to create as many stored calculations using your plug-in as you want. Now get back to barcoding your Decepticons.