D365 Business Central : Doc. No. Occurrence

“Doc. No. Occurrence” as primary key

D365 Business Central is a complex system with numerous tables and fields. In this blog post, we will explore the “Doc. No. Occurrence” field found on Purchase and Sales Headers. This field is also part of the primary key for the Purchase and Sales Header Archive, so it is good to understand its purpose.

What is the “Doc. No. Occurrence” Field?

“Doc. No. Occurrence” field

The “Doc. No. Occurrence” field is an integer field, typically displaying the value ‘1.’

While it may not be adequately documented, its function is relatively straightforward – it tracks how often a specific “No.” value has been used within the system. This tracking, in conjunction with the document number, ensures the maintenance of a unique number, particularly for archived documents.

Let’s dive into it to understand how this feature works, using the Sales Order as our example (similarly applicable to purchases).

How Does it Work?

When a new document number is generated, the “Doc. No. Occurrence” field is always set to ‘1.’

“Doc. No. Occurrence” is 1.

If you delete the order and recreate a new sales order with the same “No,” the “Doc. No. Occurrence” field increases to ‘2.’

Delete
Recreated and “Doc. No. Occurrence” field increased to 2.

This functionality depends on the Archive feature. When inserting data into the Sales Header table, the system checks the Sales Header Archive for the last recorded “Doc. No. Occurrence” and increments it by one.

When not using the Archive function, the “Doc. No. Occurrence” remains at ‘1’ because there is no Sales Header Archive record.

OnInit Sales Header

If you archive the document now and examine the Sales Order Archive, you can see where multiple documents share the same number, each distinguished by its “Doc. No. Occurrence” field.

Two documents with the same number on Sales Order Archive.

Pretty straightforward. Hopefully, you understand now why the “Doc. No. Occurrence” field is not set to one.

thatnavguy

Experienced NZ-based NAV Developer and Consultant with 15+ years of experience leading multiple IT projects, performing business analyst, developing, implementing, and upgrading Dynamics NAV and Business Central. Passionate to deliver solution that focuses on user-friendly interface while keeping high standard of compliance with the needs.

You may also like...

1 Response

  1. Ankit jain says:

    Nice information.

Leave a Reply

Your email address will not be published. Required fields are marked *