Dynamics 365 Business Central: How to check whether External Document No./Vendor Invoice No. are unique or duplicated – Customization
Developers can add customization to validate whether External Document No. and Vendor Invoice No. are unique or duplicated across both pre-posting and posted documents in Business Central, since the system does not perform this validation by default.

post Dynamics 365 Lab
"Business Central does not validate whether external document numbers are unique or duplicated."
Key points
- Business Central allows external document numbers on sales and purchase orders, invoices, and credit memos, but doesn’t validate uniqueness by default.
- A codeunit with event subscribers on Sales Header and Purchase Header tables can check for duplicate numbers in both draft and posted documents.
- The solution includes a setup flag in Sales & Receivables Setup and Purchases & Payables Setup to optionally allow duplicates.
- Validation can be scoped to specific document types or check across all documents as needed.
Quotes
- “Business Central does not validate whether external document numbers are unique or duplicated.” (Explains the gap that requires custom solution.)
- “If this kind of control is required, a small customization is necessary.” (Justifies the need for the codeunit-based approach.)
AL objects mentioned
As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.
- table 36 “Sales Header”
- table 112 “Sales Invoice Header”
- table 38 “Purchase Header”
- table 122 “Purch. Inv. Header”
- table 311 “Sales & Receivables Setup”
- table 312 “Purchases & Payables Setup”
- codeunit “ExtDocNoHandler”
Not found in BC28-30: codeunit “ExtDocNoHandler”.
Possibly related
No source states these links: they share an object, a model read them, or a person found the same subject.
- 🧩 Deriving dimensions in Business Central beyond Default Dimensions — possibly related: both name Table 112 “Sales Invoice Header”
- BC 29 lets a single index span base table and table extension fields — possibly related: both name Table 112 “Sales Invoice Header”
- BC Friday Tips #56 Understand Missing Fields in Copy Documents — possibly related: both name Table 112 “Sales Invoice Header”
- BC Friday Tips #74 Copy Document and Custom Field — possibly related: both name Table 112 “Sales Invoice Header”
- D365 Business Central: How to Fix Missing Sales Invoices in the API — possibly related: both name Table 112 “Sales Invoice Header”
- Document amount on Purchase Invoice Header — possibly related: both name Table 312 “Purchases & Payables Setup”
- Dynamics 365 Business Central: “Hide Company Bank Account” setup in General Ledger Setup (Update Company Bank Account on posted documents) — possibly related: both name Table 112 “Sales Invoice Header”
- Dynamics 365 Business Central: Copy Sales and Purchase Line Descriptions (Type G/L Account) to G/L Entries — possibly related: both name Table 312 “Purchases & Payables Setup”
- Dynamics 365 Business Central: Displaying Sales/Purchase Order No. in Item Ledger Entries (Source Order No. and Source Description) — possibly related: both name Table 112 “Sales Invoice Header”
- Dynamics 365 Business Central: How to run a Report in Preview Mode without the Request Page (Hide Request Page) — possibly related: both name Table 112 “Sales Invoice Header”
Context
- Features: external document number validation, duplicate detection, pre-posting validation, posted document checking, setup-based control, sales order validation, purchase order validation
Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.