Set Field By Name

Replaces the entire contents of a calculated target field in the current record with the calculated value.

Options 

  • Specify target field is a calculation to specify the field whose contents you want to replace.
  • Calculated result specifies the calculation whose results will be inserted by this script step.

Compatibility 

Product Supported
FileMaker Pro Yes
FileMaker Go Yes
FileMaker WebDirect Yes
FileMaker Server Yes
FileMaker Cloud Yes
FileMaker Data API Yes
Custom Web Publishing Yes

Originated in version 

10.0

Description 

The Set Field By Name script step lets you create a calculation to specify a field name, then change the value of the field either literally or based on a second calculation.

Because the target field is calculated, a single Set Field By Name step can replace multiple Set Field script steps between If conditions.

The calculated target field must return a text result.

If quotation marks are not included around the fully qualified field name, the target field name is obtained from the named field.

If no field is specified and a field is selected in Browse mode or Find mode, that field is used.

Notes 

  • The specified target field doesn't have to be on the current layout.
  • Set Field By Name ignores validation checking.
  • When possible, the Set Field By Name script step makes the record active and leaves it active until the record is exited or committed. Scripts that use a series of Set Field By Name script steps should group these steps together if possible, so that subsequent Set Field By Name script steps can act on the record without having to lock the record, download and upload data, index the field, and so on, after each individual Set Field By Name script step. These functions and record-level validation are performed after the record has been exited or committed.

Example 1 

Identifies the target field (National Statistics or World Statistics) based on geographical location, then enters a calculated value (the sum of all Grand Totals) in the target field.

Copy
Set Field by Name [If ( Customers::Country = "Japan" ; "Customers::National Statistics" ; "Customers::World Statistics" ); Sum ( Invoices::Grand Total )]

Example 2 

Demonstrates when to use Set Field By Name instead of Set Field to simplify scripts.

Copy
#With Set Field, an If statement with multiple Else If steps is needed
#to determine which field on the Customers table to update
#with information from Credit Collection::Phone Number.
Copy
If [Credit Collection::Call Location = "Work"]
    Set Field [Customers::Work Phone; Credit Collection::Phone Number]
Else If [Credit Collection::Call Location = "Home" ]
    Set Field [Customers::Home Phone; Credit Collection::Phone Number]
Else If [Credit Collection::Call Location = "Mobile" ]
    Set Field [Customers::Mobile Phone; Credit Collection::Phone Number]
End If
Copy
#A single Set Field by Name script step can perform the same task
#by using a calculation to determine the target field.
Copy
Set Field by Name [GetFieldName ( Evaluate ( Credit Collection::Call Location & " Phone" ) ); Credit Collection::Phone Number]