Year-end news for data maintenance: Rec.Truncate()

Microsoft Business Central continues to evolve to deliver optimal performance in data management. With the Wave 2 release of 2025 (BC 27), a new AL method, Rec.Truncate, will be introduced, designed to simplify and speed up the operations of massive table cleaning.

The Rec.Truncate() method allows you to delete large volumes of records in a single operation, avoiding traditional row-by-line processing. This translates into significant time savings and a more efficient use of system resources, ideal for testing, data reset or periodic archive maintenance scenarios.

How does Rec.Truncate() work?

Rec.Truncate is part of the Record API and works transparently with respect to the filters set by the developers:

  • Performs bulk deletion by skipping record-by-record.
  • When applied with filters, it first copies the data to a temporary table and restores it after the truncation operation.
  • Ensures that delete permissions are applied and skips table security filters for the current user.

Rec.Truncate provides configurable parameters to adapt to different scenarios:

  • Check if the table supports truncation.
  • Keeps the current value of the AutoIncrement fields or resets them to zero.
  • Allows you to limit the operation to only a subset of rows by filtering (useful for large amounts of data).

Use filters only on meaningful datasets: For small deletions, the temporary copy overhead can subvert the benefits.

Comparison with Deleteall()

Method

Features

Advantages

Limitations

DeleteAll

Row-by-line deletion

Simple to call

Weak performance with large tables

Rec.Truncate

Bulk truncation with filter holder

Maximum speed and flexibility

Doesn’t support OnDelete triggers and media fields

 

Limitations and fallbacks

Some conditions require attention or workarounds:

  • It doesn’t support tables with OnDelete triggers or event subscriptions (generates runtime error).
  • Excludes tables containing media or media set fields.
  • It doesn’t use FlowFields directly: it needs an approach with internal try functions.

If there are any errors, you can fall back to DeleteAll or catch the exception to handle the fallback.

Conclusion

Rec.Truncate represents an important evolution for those developing AL extensions in Business Central, dramatically improving massive data cleansing. Integrating this method into development and maintenance processes can ensure more responsive systems and continuous operation without impacting performance.

If you want to check the functionality refer to this link for the original Microsoft article.

Leave a Reply