Truncate Table

Deletes all records in the specified source table regardless of the current found set.

Options 

  • With dialog specifies whether to display a dialog box when the script step is performed, asking the user to confirm the deletion of records.
  • Current Table is the source table of the active table occurrence when this script step is performed.
  • Specify Table lets you choose a source table in the current file only.

Compatibility 

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

Originated in version 

15.0

Description 

Important  You cannot undo deleting all records.

Truncate Table attempts to lock all records in the source table before deleting them. If it can't lock all records (for example, if a record is being edited by another user), Truncate Table stops and returns an error code (which can be captured with the Get(LastError) function).

This script step may be faster than the Delete All Records script step for deleting a large number of records.

Notes 

  • Truncate Table does not delete related records even if the relationship is set up to do so (see Creating and changing relationships). To delete related records as well, use Delete All Records instead.
  • Truncate Table requires account access with the Full Access privilege set.
  • Truncate Table deletes the contents of global container fields in the specified table but doesn't delete the contents of global fields of other types.
  • If you choose Current Table and the active table occurrence when this script step is performed is from an ODBC data source, Truncate Table is skipped and returns an error code. If the active table occurrence is from an external FileMaker Pro file, Truncate Table performs normally.
  • Server-side scripts, the FileMaker Data API, and Custom Web Publishing run this script step as if the With dialog option is Off.

Example 1 

After asking the user, deletes all records in the source table named Invoices.

Copy
Truncate Table [With dialog: On; Table: "Invoices"]