Reference > Functions reference > Logical functions > GetField
 
GetField
Purpose 
Evaluates fieldName and returns the contents of the specified field.
Format 
GetField(fieldName)
Parameters 
fieldName - any text expression or text field that refers to a field’s name
Data type returned 
text, number, date, time, timestamp, container
Originated in 
FileMaker Pro 6.0 or earlier
Description 
GetField evaluates fieldName, matches the result to a field in the table on which the calculation was performed, and returns the contents of that field.
To return values of fields that have the same field name across multiple tables, enclose fieldName in double quotation marks, as in GetField("fieldName").
For example, GetField("Phone") returns a value from Customer::Phone when GetField is calculated on the Customer table, and returns Company::Phone when GetField is calculated on the Company table.
To return the values of multiple fields, do not enclose fieldName in quotation marks, as in GetField(fieldName), and specify a field that contains a value that matches the name of another field in the table. To change the value that GetField returns, change the value in the specified field to match the name of a different field in the table.
For example, a table has three fields: Customer::ContactMethod, Customer::Phone, and Customer::Email. When Customer::ContactMethod contains "Phone", GetField(ContactMethod) returns the contents of Customer::Phone. However, when Customer::ContactMethod contains "Email", GetField(ContactMethod) returns the contents of Customer::Email.
Example 1 
If you sort records on a calculation field that's defined by the GetField function, you can dynamically sort records and display subsummary data by changing the value of the field specified by GetField.
Suppose a database has four fields:
Customer Name, a text field
City, a text field
SortSelection, a global field
SortKey, a calculation field that's defined as GetField("SortSelection")
This script goes to the Invoices layout and sorts records on the SortKey field:
Go to Layout ["Invoices" (Invoices)]
Sort Records [Restore; With dialog: Off]
#Sort by the SortKey field
Go to Record/Request/Page [First]
If SortSelection contains "Customer Name", SortKey returns the values of the Customer Name field, and the found set is sorted by Customer Name. Any subsummary data specified to appear when records are sorted by SortKey is displayed from the Customer Name field.
If SortSelection is changed to contain "City", SortKey returns the values of the City field, the found set is re-sorted by City, and subsummary data is displayed from the City field.
Because the found set is sorted by SortKey, the sort information is automatically updated when the values returned by SortKey change, and you do not have to perform another sort operation.
Related topics 
Functions reference (category list)
Functions reference (alphabetical list)
About formulas
About functions
Defining calculation fields
Using operators in formulas