Archive for October, 2008

Write what you mean

Monday, October 27th, 2008

How many times have you written an expression in a calculation or a script that contains not IsEmpty ( fieldname ) ? What you are trying to write is that the field contains something - that a value, any value, exists. So wouldn't it be easier to write Exists ( Fieldname ) ? Of course it would. And you can - if you have FileMaker Pro Advanced.

The solution lies in creating a very simple custom function. FileMaker provides a lot of standard functions like the IsEmpty function. But when they do not provide, you can write your own!

To access Custom Functions, select File > Manage > Custom Functions... From there, click the New... button to create a new custom function. Then you need to define it, just like a FileMaker engineer. ;) To define a custom function, you give it a name, parameters and define what you want it to do (in an expression).

Creating the new Exists function

In this case, the function name will be Exists.

Just like its sister function IsEmpty, it will have one parameter - field. This will usually be the name of the field you are testing with the function to see if a value exists in it.

The expression for the function is simple: not IsEmpty (field )

And that's it! Click OK to save your new custom function. Click OK to close the Manage Custom Functions dialog.

Now whenever you need to use the Exists function, it will be right there in the list of functions at the top right of the calculation dialog.

Using the Exists function