Set Field By Name
Purpose 
Replaces the entire contents of a calculated target field in the current record with the result of the calculated value.
Format 
Set Field By Name[<calculated target field>; <calculated value>]
Options 
 •
Select Specify target field or click Specify to create a calculation to specify the field whose contents you want to replace. In the Specify Calculation dialog box, use the field list (on the left) and the functions list (on the right) with the mathematical and text operators to build the calculation.
 •
For Calculated result, click Specify to define the calculated value.
Compatibility 
 
Where the script step runs 
Supported 
FileMaker Pro 
Yes 
FileMaker Server scheduled script 
Yes 
FileMaker Go 
Yes 
Custom Web Publishing 
Yes 
FileMaker WebDirect 
Yes 
Runtime solution 
Yes 
Originated in 
FileMaker Pro 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
 •
 •
 •
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.
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.
#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.
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
#A single Set Field By Name script step can perform the same task
#by using a calculation to determine the target field.
Set Field By Name [GetFieldName ( Evaluate ( Credit Collection::Call Location & " Phone" ) ); Credit Collection::Phone Number]
Related topics 
Script steps reference (alphabetical list)
Script steps reference (category list)