Lose a Layout, Gain a Function

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.

2 thoughts on “Lose a Layout, Gain a Function”

  1. Hi Dawn,

    Try this instead:

    FieldNames ( Get ( FileName ) ; “” )

    Naming a layout same as table occurrence is quite advantageous in many situations. By using this calc instead, you are freed from your constraint – name your layouts anything you wish and RENAME them as well without fear of break. 🙂

    As an FYI, I know you know this but for others who might read … it is always better to use Get ( FileName ) instead of hard-coding the file name in the calc in case you change the file name later.

    Kind regards,

  2. Hi Dawn. I’m actually looking for the blog post, “Generating Field Objects via Script and XML.” I recall you demonstrated that technique in-office. Is it up here under a different name? Any ideas on where else I could find out how to do that?


Leave a Comment

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

Are You Using FileMaker to Its Full Potential?

Claris FileMaker 2023 logo
Scroll to Top