Skip to main content

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

Introduction:
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.

Pre-requisites:
  • Microsoft Dynamics NAV / Business Central
  •  VS Code 
  • AL Language Extension

Solution:
  • 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

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

Comments

Popular posts from this blog

How to Run Reports when report processing takes long to cause Session Time-out.

Introduction:
I've observed that when NAV is used for a very long time, the report which needs heavy processing takes long enough to cause Session Time-out. So, fetching reports becomes tedious by manually querying the table.

Pre-requisites:
Microsoft Dynamics NAV
Microsoft Dynamics Business Central

Solution:
The solution is simple, export the Report as an Excel or PDF depending on the data and send Email to the User as an attachment after the processing is complete.

Code:
1. Create the Report in Excel Using Excel Buffer.


2. Export the Excel Buffer contents to an XLSX file.


3. Email the Exported Files to appropriate User. In this case, I have hard coded the user email to my email.


Output:


Conclusion:
Thus adding a piece of code to send email to the User, can save a lot of hassle. In Business Central, however, it is not possible to modify an existing report. So, you need to export the existing report and merge it in AL using Text-To-Al.

How to use Forms - Flows - Business Central integration to build your masters in Business Central

Problem Statement: Few months ago on a client requirement gathering session for Business Central, I realized that the client is asking for portal where the Vendors / Customers can fill in their basic data so that the data is correct and it saves our time to prepare the master.  The easiest way of doing this was by using Microsoft Forms. In this case, I need it for Vendors, so let's see how we can use Forms, Flow and Business Central and integrate them together.

Pre- Requisites:
Microsoft Flow
Microsoft Office Forms
Microsoft Dynamics Business Central

Solution:
The solution I found was creating Form and using Flow integrate the data from the Form into Business Central
1. Create Form with fields which you want to set on the Vendors



2. Create Flow to take each record inserted in Form and integrate this record to Business Central



Output:
After inserting the data into Forms, automatically MS Flow runs to integrate this record into Business Central.





Conclusion:
Thus using MS forms, you can on…

Managing with Multiple Legal Entity Data in Microsoft Dynamics NAV / Business Central

Problem Statement:
Well, my client is a Trader of Oils & Fatty Acids and has multiple legal entities to perform various sets of operation on the TRUCK-LOAD(a.k.a. Load). One legal entity creates the Load and schedules it, while another manages with the freight requirements. The information is not shared between both the legal entities. Thus, we need to store the data separately.

Pre-requisites:
For Microsoft Dynamics NAV:
- C/Side Development Environment
- Multiple legal entity(Company) setup

For Microsoft Dynamics Business Central:
- Visual Studio Code
- AL Language Extension
- Multiple legal entity(Company) setup

Solution Design:
1. Create two Tables say LoadCompany1 and LoadCompany2 with same fields
2. Set DataPerCompany property is to TRUE on both the tables.
3. In NAV/ BC, there are common tables but the data into the tables are different. Thus, the system has to manage different version for a single table based on an entity that you're currently working on.
In this case, I n…