# OnDelete (Table Extension) trigger
> Version: _Available or changed with runtime version 1.0._
Runs when the user tries to delete a record.
## Syntax
```al
trigger OnDelete()
begin
    ...
end;
```
## Remarks
This trigger runs before the default delete behavior, which checks that the record exists before the deletion occurs. It runs automatically after the user chooses to delete a record in a page from the Web Client. If a user deletes a record using AL code, then the RunTrigger argument of ../../methods-auto/record/record-delete-method or ../../methods-auto/record/record-deleteall-method must be set to true for the OnDelete Trigger to run, or otherwise it will not. The record is not deleted if an error occurs in the trigger code.
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>
../table/devenv-ondelete-table-trigger

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/triggers-auto/tableextension/devenv-ondelete-tableextension-trigger, 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/triggers-auto/tableextension/devenv-ondelete-tableextension-trigger/
