DELETE and DELETEALL in D365 BC:
(1) Introduction: When records are deleted in the tables via “AL” then the DELETE method is used. Note: recommended to delete any record in the table, specify filters on that record using “GET” or “SETRANGE” & “SETFILTER” for getting the records which you want to delete.
(2) Syntax: DELETE.
[Ok :=] Record.DELETE([RunTrigger]) |
(3) In the below example, the Sales order document is deleted, using the DELETE and DELETE(TRUE) method as shown.
![DELETE and DELETEALL in D365 BC 1 DELETE and DELETE(TRUE) method in business central](https://erpconsultors.com/wp-content/uploads/2021/12/DELETE-and-DELETETRUE-method-in-business-central.png)
(4) Introduction: If you delete a set of records in one go, then the DELETEALL method is used.
(5) Syntax: DELETEALL.
Record.DeleteAll([RunTrigger]) |
![DELETE and DELETEALL in D365 BC 2 DeleteAll method in dynamics 365](https://erpconsultors.com/wp-content/uploads/2021/12/DeleteAll-method-in-dynamics-365.png)
(6) There is another way to delete a set of records in one go by using the “DELETE” method with REPEAT UNTIL loop as shown.
![DELETE and DELETEALL in D365 BC 3 DELTE method with REPEAT UNTIL loop in business central](https://erpconsultors.com/wp-content/uploads/2021/12/DELTE-method-with-REPEAT-UNTIL-loop-in-business-central.png)