Write to Data File

Writes data to an open data file.


  • File ID is a numeric expression that specifies the file ID of an open data file. See Open Data File script step.
  • Data source is the field or variable that contains the data to write to the file.
  • Write as writes data to the file using the default UTF-16 (little endian) character encoding used in FileMaker Pro files or UTF-8. If the data source is container data, this option is ignored and data is written as binary.
  • Append line feed adds a line feed character to the end of the data written to the file.


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

Originated in version 



Data at the read-write position in a file is overwritten by the data from Data source. See Set Data File Position script step.

The maximum amount of data this script step can write at a time is 64 MB. If the data to write is larger than 64 MB, you can perform this script step multiple times, writing an amount no larger than 64 MB each time.


  • Performance is best when writing no more than 64 KB.

Example 1 

Writes the contents of a variable followed by a line feed as UTF-8-encoded text to the open data file with a file ID of 2.

Write to Data File [ File ID: 2 ; Data source: $variable ; Write as: UTF-8 ; Append line feed ]

Example 2 

Checks whether a file in the Documents folder named change.log exists, creates it if it doesn’t exist, writes data from the Activity::Transaction field to the beginning of the file, and closes the file.

Set Variable [ $file ; Value: Get ( DocumentsPath ) & "change.log" ]
Get File Exists [ "$file" ; Target: $fileExists ]
If [ not $fileExists ]
    Create Data File [ "$file" ; Create folders: Off ]
End If
Open Data File [ "$file" ; Target: $fileID ]
Write to Data File [ File ID: $fileID ; Data source: Activity::Transaction ; Write as: UTF-8 ; Append line feed ]
Close Data File [ File ID: $fileID ]

Example 3 

Writes data from a field to a specific position in the file named dates.txt. Before the script runs, the file contains 2024-11-30 and the Table::Month field contains 12. After the script runs, the file contains 2024-12-30.

Open Data File [ "dates.txt" ; Target: $fileID ]
Set Data File Position [ File ID: $fileID ; New position: 5 ]
Write to Data File [ File ID: $fileID ; Data source: Table::Month ; Write as: UTF-8 ]
Close Data File [ File ID: $fileID ]