Replaces the entire contents of the specified field in the current record with a calculation result.
- Specify target field specifies the field whose contents you want to replace. If no field is specified and a field is selected in Browse mode or Find mode, that field is used.
- Calculated result is the calculation whose results will be inserted by this script step.
|FileMaker Cloud products||Yes|
|FileMaker Data API||Yes|
|Custom Web Publishing||Yes|
Originated in version
6.0 or earlier
- The result of the calculation must match the field type. For example, you can't assign a date calculation to a container field.
- The specified field doesn’t have to be on the current layout.
- If the result of the calculation doesn’t match the target field type, and the validate option for the field is set to Always, the field will not be set and an error code is returned (which can be captured with the Get(LastError) function).
- When possible, the Set Field 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 script steps should group these steps together if possible, so that subsequent Set Field 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 script step. These functions and record level validation are performed after the record has been exited or committed.
- If the target field is a repeating field, you can specify a repetition number or generate a repetition number from a calculated expression.
Inserts the sum of the invoices' grand totals into the Statistics field.
Set Field [Customers::Statistics; Sum ( Invoices::Grand Total )]
Demonstrates when to use Set Field instead of Set Field By Name to simplify scripts.
#If the target field does not change, use the Set Field script step.
Set Field [Customers::Work Phone; Credit Collection::Phone Number]
#If you use Set Field by Name with a target field that does not change,
#you must surround the target field in quotation marks so it evaluates as a literal string
#and returns the specified field name. If you do not use quotation marks,
#Set Field by Name evaluates the specified field and uses the result as the target field.
#If the result does not specify a field name, nothing happens.
Set Field by Name ["Customers::Work Phone"; Credit Collection::Phone Number]