community postSales & Receivablescommunity - not Microsoftreviewed - checked by Opus

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

Yun Zhu · 2025-12-18 · 607 words · about 3 min

"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.

Not found in BC28-30: codeunit “ExtDocNoHandler”.

No source states these links: they share an object, a model read them, or a person found the same subject.

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.