Reference > Script steps reference > Fields script steps > Replace Field Contents
 
Replace Field Contents
Purpose 
Replaces the value in a field in every record in the found set with a different value.
See also 
Format 
Replace Field Contents [With dialog: On/Off; <table::field>;
Current contents/Serial numbers/Calculation results]
Options 
With dialog specifies whether to display the Replace Field Contents dialog box when the script step is performed.
Specify target field specifies the target field for the replace operation.
Replace with "current contents" uses the current value in the specified field as the replacement value to place in that field in every other record in the current found set.
Replace with serial numbers reserializes the field in every record in the current found set.
Entry options uses the next available value in Entry Options as the first record number, incrementing with whatever value is in Entry Options.
Custom Values lets you enter a value to be used as a starting point for the serialization, as well as a value by which to increment each serialized field in the current found set.
Update serial number in Entry Options? resets the serial number value in Entry Options so that the next serial number that is automatically entered will follow the records you have reserialized with this script step. If this option is not used, the serial value in Entry Options is not changed, and may not be in sequence with the newly reserialized records.
If the field to be replaced was set up for auto-entry of a serial number and Prohibit modification of value is not selected, FileMaker Pro will still put sequential numbers in the selected field, but will do so starting with the next number to be automatically entered.
Replace with calculated result displays the Specify Calculation dialog box, where you can enter a calculation to be used as the replacement value.
Compatibility 
 
Where the script step runs 
Supported 
FileMaker Pro 
Yes 
FileMaker Server 
Partial 
FileMaker Go 
Partial 
Custom Web Publishing 
Partial 
FileMaker WebDirect 
Partial 
Runtime solution 
Yes 
Originated in 
FileMaker Pro 6.0 or earlier
Description 
This script step uses the value in a specified field in the current record or uses a calculation to replace the value in that field in every record in the current found set.
Important  Replace Field Contents modifies all records in the found set. You cannot undo a Replace Field Contents script step.
This script step can also be used to reserialize a field in every record in the current found set.
When you use the Replace Field Contents script step, the data must be committed first before the operation is performed, or you may get unexpected results. See Committing data in records.
FileMaker WebDirect, server-side scripts, and Custom Web Publishing run this script step as if the With dialog option is set to Off.
FileMaker Go does not support the With dialog: On option.
Example 1 
Assigns serial numbers to all invoices in the found set.
Sort Records [Restore; With dialog: On]
Go to Record/Request/Page [First]
Replace Field Contents [With dialog: Off; Invoices::Invoice ID; Serial numbers]
Example 2 
Replaces the contents of the Customer ID field in all records in the found set with the contents of the current record's Customer ID field.
Perform Find [Restore]
Replace Field Contents [With dialog: Off; Invoices::Customer ID; Current Contents]
Related topics 
Defining calculation fields
Script steps reference (alphabetical list)
Script steps reference (category list)