GetFieldsOnLayout
Returns a list of the fields on a layout as JSON data.
Format
GetFieldsOnLayout ( layoutName )
Parameters
layoutName - a text expression representing the name of the layout. If layoutName is an empty string (""), the current layout is used.
Data type returned
text
Originated in version
22.0
Description
This function returns a JSON object containing information about fields on the specified layout that are accessible to a find.
Fields that meet any of the following criteria are excluded:
-
The field object is outside the layout area (see Placing and removing fields on a layout).
-
The Hide object when condition is met and Apply in Find mode is selected (see Hiding or showing layout objects).
-
For Field entry, Find Mode is unselected (see Allowing or preventing entry into fields).
-
Include field for Quick Find is unselected (see Configuring quick find).
-
The current account's privilege set has no read access (Editing record access privileges).
-
The field is a summary, global, or container field (see Defining summary fields, Defining global fields (fields with global storage), and About container fields).
The returned JSON object has the following structure:
{
"layout_name": "LayoutName",
"fields": {
"TableOccurrence::FieldName1": {
"type": "string",
"description": "Field annotation or comment (optional)"
},
"TableOccurrence::FieldName2": {
"type": "number"
}
}
}
-
The
layout_namekey contains the name of the layout. -
The
fieldsobject contains key-value pairs for each accessible field. -
Each field's key is its fully qualified name (for example, TableOccurrence::FieldName).
-
Each field's value is an object with a
typekey (numberif the field's data type is number; otherwise,string). -
An optional
descriptionkey is included if the field has an annotation (see Defining advanced field options) or a comment (see Defining and changing fields) defined in the Manage Database dialog. If a field has both, the annotation is used as the value of thedescriptionkey. If a field has only a comment, then the comment is used. If either starts with[LLM], the[LLM]prefix is removed for backward compatibility with the[LLM]tag convention used in versions earlier than FileMaker 26.0.1.
Notes
-
This function uses the same criteria to determine which fields are accessible by a find and what field information is returned as the Perform Find by Natural Language script step does.
Example 1
Returns a JSON object describing the fields accessible to a find on the Products layout.
JSONFormatElements ( GetFieldsOnLayout ( "Products" ) )
If the Products layout has these fields:
| Field name | Annotation | Comment |
|---|---|---|
|
CreationDate |
Creation date for product |
|
|
Price |
Price of the product in USD |
|
|
ProductID |
Primary key that uniquely identifies a product |
Product ID |
|
ProductName |
|
[LLM] Descriptive name of the product |
|
Status |
|
|
|
g_UserFavorites |
Global field containing the current user's favorite products |
The function returns:
{
"fields" :
{
"Products::CreationDate" :
{
"description" : "Creation date for product",
"type" : "string"
},
"Products::Price" :
{
"description" : "Price of the product in USD",
"type" : "number"
},
"Products::ProductID" :
{
"description" : "Primary key that uniquely identifies a product",
"type" : "number"
},
"Products::ProductName" :
{
"description" : "Descriptive name of the product",
"type" : "string"
},
"Products::Status" :
{
"type" : "string"
}
},
"layout_name" : "Products"
}
Notice the following:
-
ProductID: The
descriptionkey contains the annotation (the comment is ignored). -
ProductName: The
descriptionkey contains the comment with the[LLM]prefix removed (no annotation exists). -
Status: No
descriptionkey appears (no annotation or comment exists). -
g_UserFavorites: The field is omitted entirely (global fields aren't accessible to a find).
Example 2
Returns a list of all fields on the current layout and a list of all fields on the current layout that are accessible by a find. This may point out fields that you weren't aware were not accessible to a find.
Let (
[
layoutFields = FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ;
findFields = JSONListKeys ( GetFieldsOnLayout ( Get ( LayoutName ) ) ; "fields" ) ;
sortedLayoutFields = SortValues ( layoutFields ; 1 ) ;
sortedFindFields = SortValues ( findFields ; 1 ) ;
$$result = "All fields on the current layout:" & ¶ & sortedLayoutFields & ¶ &
"Of these, the fields accessible to a find are:" & ¶ & sortedFindFields
] ;
$$result
)
Possible output stored in $$result for the Products layout:
All fields on the current layout:
CreationDate
Photo
Price
ProductID
ProductName
Status
Of these, the fields accessible to a find are:
Products::CreationDate
Products::Price
Products::ProductID
Products::ProductName
Products::Status