{"title":"OnDelete (Table) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/table/devenv-ondelete-table-trigger/","by":"JOP-AL","license":"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/table/devenv-ondelete-table-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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/table/devenv-ondelete-table-trigger","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Runs when a user tries to delete a record.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":103,"chars":58},{"level":2,"title":"Remarks","slug":"remarks","at":161,"chars":543},{"level":2,"title":"Related information","slug":"related-information","at":704,"chars":210}],"text":"> Version: _Available or changed with runtime version 1.0._\nRuns when a user tries to delete a record.\n## Syntax\n```al\ntrigger OnDelete()\nbegin\n    ...\nend;\n```\n## Remarks\nThis 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.\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\nOnDelete (Table Extension) Trigger<../tableextension/devenv-ondelete-tableextension-trigger>"}