BCQuality rule · data-modelingAL Developmentofficial - Microsoftderived - from the source, no model text

Scope sales header attachment cleanup by document type

In the BC 29 source, a Sales Header is identified by Document Type and No., and its Document Attachment records carry the table ID, document number, and attachment document type. A quote and an order can therefore have the same number without being the same owner.

Rule on GitHub · microsoft layer · data-modeling · BC 29 · tier official · derived

Description

In the BC 29 source, a Sales Header is identified by Document Type and No., and its Document Attachment records carry the table ID, document number, and attachment document type. A quote and an order can therefore have the same number without being the same owner. Custom cleanup filtered only by table ID and number can delete both owners’ attachments.

Best Practice

For cleanup intended for one sales header, pass its RecordRef to Document Attachment Mgmt.DeleteAttachedDocuments, which applies the owner filters before deleting. If custom filtering is necessary, include the matching document type as well as the table ID and number, and retain any additional filters required by the actual operation and extensions. Do not assume the same dimensions identify every other table’s attachments. Deletion can also affect external storage through installed extensions; verify that lifecycle separately.

See sample: scope-sales-header-attachment-cleanup-by-document-type.good.al.

Anti Pattern

Custom code deletes Document Attachment records for one Sales Header using only Table ID and No., without restricting Document Type. It can remove attachments for a different sales document with the same number. Do not flag a deliberately cross-type operation whose intended scope includes those documents, or code that already constrains the type.

See sample: scope-sales-header-attachment-cleanup-by-document-type.bad.al.

References

Examples

Names

Changed by


From microsoft/BCQuality at 863acaa, MIT License, Copyright (c) 2026 Microsoft Corporation (license).