The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
DELETEALL Method (RecordRef)
Deletes all records in a table that fall within a specified range.
Identifies the table in which the deletion will occur. Only those records selected by the filters set for RecordRef are deleted.
Specifies whether the code in the OnDelete trigger will be executed. If this parameter is true, the code will be executed. If this parameter is false (default), the code will not be executed.
This parameter is optional.
This method works the same way as the DELETEALL Method (Record).
The following example opens table 18 (Customer) as a RecordRef variable that is named CustomerRecRef. The FIELD Method (RecordRef) creates a FieldRef variable that is named MyFieldRef for field 1 (No.). From the No. field, the SETRANGE Method (FieldRef) selects records in the range from 10000 to 20000. The number of records in the range is displayed in a message box. The DELETEALL method deletes all records in that range. The number of records is displayed again. This time, 0 is displayed because all the records in the range are deleted. This example requires that you create the following global variable and text constant.
|Text constant name||DataType||ENU value|
|Text000||Text||The number of records in the range is %1.|
CustomerRecRef.OPEN(18); MyFieldRef := CustomerRecRef.FIELD(1); MyFieldRef.SETRANGE('10000' , '20000'); MESSAGE(Text000 ,CustomerRecRef.COUNT); CustomerRecRef.DELETEALL; MESSAGE(Text000 ,CustomerRecRef.COUNT);