Dynamics 365 Business Central: Searches for duplicate external document numbers in sales documents and posted documents (Standard function/procedure)
Business Central provides a standard method to search for duplicate external document numbers in sales documents and posted documents. The SearchForExternalDocNo procedure in codeunit 1302 validates duplicates for the same customer, though it only checks within individual customer records rather than across all customers.

post Dynamics 365 Lab
"Business Central does not validate whether external document numbers are unique or duplicated."
Key points
- Standard function SearchForExternalDocNo in codeunit 1302 detects duplicate external document numbers
- Checks both unposted sales headers and posted sales invoices or credit memos
- Validation is limited to duplicates within the same customer, not across all customers
- Returns true if duplicate found, false otherwise
Quotes
- “Business Central does not validate whether external document numbers are unique or duplicated.” (Explains why implementing duplicate detection requires either standard procedures or customization)
- “this standard method has a limitation: it only checks for duplicate External Document No. for the same customer” (Important constraint for developers to understand when implementing validation logic)
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.
- codeunit 1302 “Customer Mgt.”
- table 36 “Sales Header”
- table 112 “Sales Invoice Header”
- table “Sales Cr. Memo Header”
Not found in BC28-30: table “Sales Cr. Memo Header”.
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”
- 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: 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 check whether External Document No./Vendor Invoice No. are unique or duplicated – Customization — 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”
- Leveraging RecordRef and FieldRef for Dynamic Coding — possibly related: both name Table 112 “Sales Invoice Header”
Heads up
- gotcha: “This standard method has a limitation: it only checks for duplicate External Document No. for the same customer, rather than across all customers.” (about codeunit Customer Mgt.)
Context
- Features: external document number validation, duplicate detection, sales order processing, invoice management, credit memo processing
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.