Faster Data Cleanup in Business Central 2025 Wave 2 (BC27) with the New Rec.Truncate() Method

With the 2025 Wave 2 release (BC 27), Microsoft Dynamics 365 Business Central introduces a new AL method: Rec.Truncate(). This method is designed for high-performance data deletion, allowing you to quickly clear large datasets—ideal for testing, data resets, and periodic maintenance.

What Is Rec.Truncate()?

Rec.Truncate() is part of the Record API and enables bulk deletion of records in a single operation—bypassing slow row-by-row deletion like DeleteAll().

Key benefits:

  • Mass deletion with better performance

  • Honors filters applied by developers

  • Skips record-by-record processing

  • Bypasses security filters but still respects delete permissions

Main Features

FeatureDetails
Filters supportCopies filtered data to a temp table, deletes, then restores
AutoIncrement fieldsCan be reset or preserved
Flow controlSupports fallback to DeleteAll() on failure
Fast and configurableIdeal for large tables

Limitations to Note

  • ❌ Doesn’t support OnDelete triggers or event subscribers

  • ❌ Not usable on tables with Media or MediaSet fields

  • ❌ Doesn’t handle FlowFields directly

  • 🛠️ Use try blocks for safe fallback to DeleteAll()

Rec.Truncate() vs DeleteAll()

MethodProsCons
DeleteAll()Simple, supports triggersSlow on large tables
Rec.Truncate()Fast, efficientLimited to trigger-free, non-media tables

When Should You Use It?

  • Data resets in test environments

  • Cleaning up temporary or historical data

  • Improving performance in archive jobs

Final Thoughts

Rec.Truncate() is a powerful enhancement for Business Central developers. It boosts performance for large-scale deletions and simplifies data management workflows. Add this to your toolkit for cleaner, faster, and more scalable AL solutions.

👉 Check out Microsoft’s official documentation here

Stay tuned for more updates..!

Leave a Reply

Your email address will not be published. Required fields are marked *