Reference > Script steps reference > Records script steps > Export Records
 
Export Records
Purpose 
Exports records to a specified file.
See also 
Format 
Export records [With dialog: On/Off; "<output filename>"; Automatically open; Create email; <platform and character set>]
Options 
With dialog specifies whether to display dialog boxes when the script step is performed. These dialog boxes let the user set new export criteria.
Specify output file allows you to specify the file and file type to export. Choose the folder you want to export to, or type the folder path directly into the list. Specify one path per line. FileMaker Pro will use the first path it locates. See Creating file paths. The file type you use depends on the import requirements of the program using the exported data. You can also specify options to Automatically open the file and Create email with the file as attachment after saving.
If FileMaker Pro executes a script that does not specify an absolute path, and the database file containing the script is hosted, the path is assumed to be the current user’s Documents folder.
Note  You can export records as a Microsoft Excel worksheet by choosing Excel Workbooks (.xlsx). For more information on saving FileMaker Pro files as Excel files, see Saving and sending records as an Excel file.
If you specify XML as the export file type, the Specify XML and XSL Options dialog box appears, where you can specify an XML grammar and choose an XSLT style sheet if you want to transform the XML. The XSLT source may be a file, the result of an HTTP request, or a calculation that generates a file path or an HTTP request.
Note  Do not export fields whose name is entirely numeric (such as "2") or whose name is a single-byte kana character (Japanese version) using the FMPDSORESULT grammar.
Specify export order uses the export order that was in effect when you added the script step. The last export order used in the file appears as the default and can be edited or deleted. If necessary, choose an output file character set from the list. Select Apply current layout’s data formatting to exported data, or the formatting of the last exported data will be used.
Compatibility 
 
Where the script step runs 
Supported 
FileMaker Pro 
Yes 
FileMaker Server 
Partial 
FileMaker Go 
Partial 
Custom Web Publishing 
No 
FileMaker WebDirect 
Partial 
Runtime solution 
Yes 
Originated in 
FileMaker Pro 6.0 or earlier
Description 
You can set the export order before adding this script step, or perform the step with a dialog box so a user can set new criteria. Export Records exports all the records currently being browsed. If you want to limit the set of records you're exporting, use a find request before using Export Records.
If you include this script step in a server-side script and you do not set With dialog to Off, the text (NOT compatible) appears in the script step. The script, however, will run. The behavior will be the same as if With dialog is Off. See Get(DocumentsPathListing) function for more information.
Notes 
FileMaker Server does not support exporting to the FMP12 format.
Scripts performed by FileMaker Server follow FileMaker Server file path behaviors. See Paths in server-side scripts.
In FileMaker Go, exporting to .fmp12 and XML formats is not supported.
When using this script step in FileMaker WebDirect, keep the following in mind:
FileMaker WebDirect does not support this script step in mobile browsers.
FileMaker WebDirect does not support exporting to FMP12, XML, or XLS or XLSX formats.
If the Specify output file option is selected, FileMaker WebDirect outputs exported records with the specified filename and file type but ignores the specified file path.
FileMaker WebDirect outputs exported records to the web browser’s default download location.
If field data or record data is too long for the export format, the Get(LastError) function returns 0 rather than 736.
Example 1 
Finds and sorts records, then exports the found set as an Excel file without prompting the user.
Go to Layout ["Invoices"]
Perform Find [Restore]
Sort Records [Restore; With dialog: Off]
Export Records [With dialog: Off; "Unpaid Invoice List.xlsx"; Unicode (UTF-16)]
Example 2 
Exports the found set as an Excel file unless a file with that name already exists in the output directory.
If [not PatternCount ( Get ( DocumentsPathListing ); "Unpaid Invoice List.xlsx" )]
Export Records [With dialog: Off; "Unpaid Invoice List.xlsx"; Unicode (UTF-16)]
End If
Related topics 
Import Records script step
Save Records As PDF script step
Save Records As Excel script step
Script steps reference (alphabetical list)
Script steps reference (category list)