Dynamics 365 Business Central: Searches for duplicate external document numbers in sales documents and posted documents (Standard function/procedure)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to talk about how to search for duplicate external document numbers in sales documents and posted documents using standard function/procedure.

In Business Central, you can enter external document numbers for customers and vendors in all sales and purchase orders, invoices, and credit memos. For example,
On the Sales Order: External Document No.

On the Purchase Order: Vendor Invoice No.

In Dynamics 365 Business Central: Set External Document No./Vendor Invoice No. as mandatory (Ext. Doc. No. Mandatory), we briefly discussed how to set External Document No./Vendor Invoice No. as mandatory. As mentioned briefly, Business Central does not validate whether external document numbers are unique or duplicated. If this kind of control is required, a small customization is necessary. We’ve discussed this before, and at that time we also used a custom approach where I wrote the functions from scratch. More details: Dynamics 365 Business Central: How to check whether External Document No./Vendor Invoice No. are unique or duplicated – Customization. Recently, by chance, I discovered that there is actually a standard method for it.

codeunit 1302 “Customer Mgt.” -> procedure SearchForExternalDocNo

Searches for duplicate external document numbers in sales documents and posted documents: True if a duplicate external document number is found, otherwise false.

We can see that this standard method first searches all Sales Header, and if found, returns true. For posted data, if the type is Invoice or Order, it will look for the Sales Invoice Header to see if it can be found; if the type is Credit Memo, it will look for the Sales Cr. Memo Header. Also, this standard method has a limitation: it only checks for duplicate External Document No. for the same customer, rather than across all customers. If you don’t need this restriction, you’ll need to rewrite it based on this standard approach, which isn’t too difficult.

Let’s do a simple test.

Very simple.

Great, give it a try!!!😁

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL