Skip to main content

Generate Number Series from one Company and use it in another company

When dealing with Number Series where the Intercompany Documents are created automatically using the code, using standard number series generation Codeunits cause problems. In this blog, I'll be explaining why this issue is caused and how to resolve such issues.

  • Microsoft Dynamics NAV / Business Central
  •  VS Code 
  • AL Language Extension

  • Issue:
Let's say I'm logged in as user of Company B. When I create Sales Order in current company, I need to create Purchase Order in target company say Company A.
When I use the Number Series declared on Company B's Purchase and Payable Setup for Purchase Order, the system either gives an error that Number Series does not exist or number generated is out of sync as Number Series are stored on Per Company basis. This results in overlapping of next PO number to be generated.

  • Cause of the Issue:
NoSeriesManagement Codeunit 396 works only with the No. Series for the current company. Because of this if the No. Series with same code is present, the system generates No. Series which is completely different than that of the Company B. Also, there is no synchronization mechanism available out of the box to do the Intercompany No. Series sync.

Create the same Number Series in both the entities:
The Number Series is to be created in the primary company(Company A). The code mentioned below will automatically create the number series in the target company(Company B) from Company A.

Code to automatically Insert No. Series 

Prior to Creating Number Series

After the creation of Number Series

Modifying the Number Series back to Company A from Company B:
Using this function, I modified the newly created number series back to the original company.

Declare the Number Series and CompanyName to be used in Setup:
In Company A, I've created Number Series in General Ledger Setup. Using this No. Series declared in Company A use this No. Series to create Purchase Order in the same company through Company B.

Use ChangeCompany() to the target company(Company B) where you want to create the document. Modify the Number Series Line from Company B in Company A using a function.

Code to copy number series from Company A to Company B, generate the new number series and modify the number series back in Company A from Company B

In this way, we can generate a number series for one company from another company.


Unknown said…
Maybe it is easy and more correct if you could copy the GetNextNo3 function and SetNoSeriesLineFilter copy to your local report or code unit and u could change the tables changecompany property and then managed it easily rather than searching and filtering data manually table level.
The task to accomplish is to have number series in both the companies to be in sync.
Importantly, if I create PO from company A with PO No. PO0001 and when I generate intercompany PO from Company B into Company A, it is needed for me to continue with the number series. Secondly, GetNextNo3 only work when you have Number Series defined in the Company B and without the No. Series in sync, there will be an error saying that the number already exists in Company A.

Popular posts from this blog

How Business Central Modern Client Reverse Compatibility With NAV Can Help You Improve Your Work.

Introduction: Today, I was playing around with Business Central Modern Client (Windows App).
Out of curiosity I was trying to login to one of my NAV 2017 through SSO.
Pre-requisites: Microsoft Dynamics NAV with SSO configured
Microsoft Dynamics Business Central
Demonstration: 1. Business Central App - Main Page:

Clicking on locally hosted service and putting in the credentials configured for NAV 2017 SSO, we get.
Still skeptical when Business Central login into NAV.

2. Business Central App - Reverse compatible with NAV 2017:

Well well well...
Look whose here.
NAV disguised as  Dynamics 365 for Financials.

I think we all agree that Business Central Modern Client is a WebApp version of Busines Central Online. Basically just like browser in an App.
The difference is that it can connect to NAV as it is just like a browser.

3. Does Business Central Modern Client follow DynamicsNAV protocol?:
Well, it simply does not.
It would be amazing  if it did, as it would mean that we could deal with runni…

TIP: Working with changing Field DataTypes and Deleting fields in Business Central

Imagine a scenario where as per the requirements provided by your clients, you have set up the Database structure in NAV/Business Central.
Then comes a requirement in Phase 2 which completely redefines the database structure which was provided by you and you need to delete a few fields in a table and move it to another table.

Microsoft Dynamics NAV
Microsoft Dynamics Business Central

Books & References:

1. In Microsoft Dynamics NAV, there was a flexibility to delete fields, tables, and keys and using  Force-Sync, you can directly delete the field, table, and keys from SQL Database.

2. Whereas in Microsoft Dynamics Business Central, you cannot delete the fields, keys, and tables.
In order to deploy this deleted change, you need to mention this field, table, and keys with Obsolete State Removed.

After you mention the field as…

How to actually use Profile Objects in Business Central

To 'Whomsoever This May Concern',
When I was working on a Production Deployment for one of my clients, I noticed that I could not create a Profile in Business Central Production Tenant. I was able to create new Profile in Sandbox.

Then I tried using configuration Package and modify the contents of 2000000178 Profile Table and as always configuration package blocked it.

There was no way of dealing with this other thancontacting Microsoft Support and this is the answer I get from a Support Engineer

I was on the verge to give my clients a link pointing to a specific page i.e

After being a little creative, I figured out that developing profile objects might help.

And this resolved this issue for me.