You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »


Within FileMaker code, it is possible to make literal evaluations. A simple line such as the following can cause significant problems within any FileMaker solution.

If [ Get ( LayoutName ) = "Customer Details"]

As soon as you change the name of the layout to "Customer Detail" (without the "s") your code is invalid. To solve this issue:

  • No objects should be referenced within calculation code via literal strings or absolute names. The ObjectID custom function (created by Fabrice Nordmann) is used as an abstraction to reference FileMaker objects.
    If [ Get ( LayoutName ) = ObjectID ( 37 ; "Layout" ; null ; null ) ] Go To Layout [ "XYZ" ]


    If [ Get ( LayoutName ) = "People: Customer Details" ] Go To Layout [ "XYZ" ]


The good code above will self-adjust when the name of the Layout is arbitrarily changed - as opposed to the literal reference of "People: Customer Details".


Using the ObjectID custom function should not be handled in a direct manner. In order words. Your code should not make the calls shown above. The goal of these standards is to create clear reading code.

The ObjectID custom function should be added as a private custom function using the tilde nomenclature. ~ObjectID. This provides the immediate indication that this function is called by other functions and not directly.

This best practice suggests you use a "class prefix" for custom functions which deal with certain FileMaker elements. Here is an example of script code:

If [ LayoutIsCustomerDetails ]
    # Do layout specific steps here...
End If

Where LayoutIs[nameOfLayout] is the prefix to all custom functions used to verify the layout. Here is the LayoutIsCustomerDetails custom function.

// Object reference to Customer Detail layout

~ObjectID ( 4 ; "Layout" ; Null ; Null )

Where the value of "4" was determined by using the same ~ObjectID custom function within the Data Viewer in the format of ~ObjectID ( "Customer Details" ; "Layout" ; Null ; Null ) in order to determine the internal id of the Layout.

ObjectID Custom function on Github

  • No labels