There is a rather obscure but very useful feature available in one of the FileMaker design functions. The function FieldNames ( fileName ; layoutName ) ostensibly returns a list of the fields on the requested layout in the specified file. Nothing surprising there, but what if the layout you specify does not exist in the file? Aha! That’s when some interesting behavior kicks-in.
If, instead of passing the function FieldNames a layout name for the second parameter, you pass it the name of a table occurrence, FileMaker will return the full list of fields for said table occurrence. Fantastic! Of course, to make use of this behavior, you cannot have a layout with the same name as the table occurrence. So here’s one of my FileMaker development best practices…never, ever, EVER name a layout with the same name as a table occurrence.
Strangely enough, when you make a new table FileMaker creates a layout with the same name as the table occurrence. Do yourself a favor: chuck the layout, or at least rename it, and add a neat new function to your developer toolkit.
In a future posting to be titled “Generating Field Objects via Script and XML”, I’ll explain how you can leverage the FieldNames function to manage development layouts. It will include a great demonstration file that you won’t want to miss.