# RecordRef.Truncate([Boolean]) Method
> Version: _Available or changed with runtime version 16.0._
Deletes all records in a table that fall within a specified range, in an efficient maner. Keep in mind that Truncate allows for less concurrency than DeleteAll, as the entire table will be locked until the transaction is committed.
## Syntax
```al
[Ok := ]  RecordRef.Truncate([ResetAutoIncrement: Boolean])
```
## Parameters
RecordRef
Type: recordref-data-type
An instance of the recordref-data-type data type.
*[Optional] ResetAutoIncrement*
Type: ../boolean/boolean-data-type
Specifies if the AutoIncrement column should be reset to start from the initial value, or if it should stay at the current value.
Tables without an AutoIncrement field ignore this parameter. The default is true.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
true if the table supports truncate; otherwise, false.
If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Remarks
Truncate currently isn't supported in the following cases:
 Temporary tables, system tables, and tables of type other than Normal.
 When running within a try function.
 Tables that have a security filter applied.
 When the current filters contain flow fields, or use a high number of marked records.
 When the OnAfter/OnBefore events are subscribed for the table.
 Tables with media fields.
In this case, it's recommended to use DeleteAll instead.
## Example
The following example demonstrates how to truncate all records in a table and capture the optional return value to avoid a runtime error when truncate isn't supported.
```al
procedure ExampleTruncate_RecordRef()
var
    RecRef: RecordRef;
    Ok: Boolean;
begin
    RecRef.Open(50101);
    Ok := RecRef.Truncate(true);
    RecRef.Close();
    if Ok then
        Message('RecordRef: Truncate succeeded and AutoIncrement reset.')
    else
        Message('RecordRef: Truncate not supported; consider DeleteAll.');
end;
```
The following example demonstrates how to truncate records matching a filter (in this case the table's "Location Code" field). This approach is only recommended when the majority of records match the filter because Truncate is most efficient in such scenarios.
```al
procedure ExampleTruncateFiltered_RecordRef()
var
    RecRef: RecordRef;
    Ok: Boolean;
begin
    RecRef.Open(50101);
    // Field number 2 corresponds to Location Code in this table
    RecRef.Field(2).SetFilter('Red');
    Ok := RecRef.Truncate(false);
    RecRef.Close();
    if Ok then
        Message('RecordRef: Filtered truncate (Location=Red) succeeded (AutoIncrement preserved).')
    else
        Message('RecordRef: Filtered truncate not supported; consider deleting manually.');
end;
```
## See Also
Insert, Modify, ModifyAll, Delete, DeleteAll, and Truncate methods<../../devenv-insert-modify-modifyall-delete-and-deleteall-methods>
Record.Truncate([Boolean]) method<../record/record-truncate-method>
recordref-data-type
Getting started with AL<../../devenv-get-started>
Developing extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-truncate-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-truncate-method/
