Using CHANGECOMPANY and NoSeriesManagement
jversusj
Member Posts: 489
I searched the forum for this particular issue and could not find anything directly related to it.
I am trying to write a process that will take a customer created in one Navision company and create that customer in a second Navision company on the same database (although with a different customer no.).
I am using CHANGECOMPANY effectively to the point that I am able to create the customer (with all demographics) in the second company, but I am having a heck of a time with the NoSeries reading from the Second Company. Instead, it uses the NoSeries of the current company.
I know that the SalesSetup (S&R Setup table) for the 2nd company is called because I changed the Customer No. Series code to something wacky and saw that wacky value in Debugger...unfortunately it used the wacky number series from Company 1 and not 2. frown.
Here's the gist of my code
where do I need to add a change company to get the NoSeries right? I don't have access to Codeunits, but i can turn on code coverage and copy the functions out and to my own report if necessary.
thanks in advance!
I am trying to write a process that will take a customer created in one Navision company and create that customer in a second Navision company on the same database (although with a different customer no.).
I am using CHANGECOMPANY effectively to the point that I am able to create the customer (with all demographics) in the second company, but I am having a heck of a time with the NoSeries reading from the Second Company. Instead, it uses the NoSeries of the current company.
I know that the SalesSetup (S&R Setup table) for the 2nd company is called because I changed the Customer No. Series code to something wacky and saw that wacky value in Debugger...unfortunately it used the wacky number series from Company 1 and not 2. frown.
Here's the gist of my code
ItalyCust.RESET; //ItalyCust = customer table
ItalyCust.INIT;
SalesSetup.CHANGECOMPANY(CompanyRec.Name);
SalesSetup.GET;
SalesSetup.TESTFIELD("Customer Nos.");
NoSeriesMgt.InitSeries(SalesSetup."Customer Nos.",ItalyCust."No. Series",0D,ItalyCust."No.",ItalyCust."No. Series"); //codeunit NoSeriesManagement
//...some field equalities...
DefaultsT.CHANGECOMPANY(CompanyRec.Name);
DefaultsT.GET;
//...some defaults in the second company being written to the new customer record...
IF ItalyCust.INSERT THEN...
//...some post insert stuff
where do I need to add a change company to get the NoSeries right? I don't have access to Codeunits, but i can turn on code coverage and copy the functions out and to my own report if necessary.
thanks in advance!
kind of fell into this...
0
Answers
-
One of the problems you will have using CHANGECOMPANY it's that validations are still done in the current company.
InitSeries Call a function called GetNextNo.
GetNextNo uses VALIDATION :-(0 -
Thank you!nunomaia wrote:One of the problems you will have using CHANGECOMPANY it's that validations are still done in the current company.
InitSeries Call a function called GetNextNo.
GetNextNo uses VALIDATION :-(
So, in theory, if I manually recreate the InitSeries string of events in my report and stick a few more CHANGECOMPANYs in, I can get the NoSeries from the destination company?kind of fell into this...0 -
You'd have to add a companyname parameter to all of the functions, or add a function to set a global company name variable.
I would probably duplicate the code into a new function with a company name parameter, much like an overload.0 -
yep,
DenSter comment is the way to go.0 -
thanks everyone.
i'm currently trying to recreate the functions in my report. i'm experiencing a disconnect where the SetNoSeriesLineFilter function finds the right no series, but then it is forgotten when the code jumps back to the GetNextNo function. Once i resolve that, i should be okay and be able to proceed. i won't mark this solved just yet, but i will when i have it wrapped up.
edit:
I figured this out with a little trickery. i had to move the logic from the SetNoSeriesLineFilter to the GetNextNo function (actually the analogs in my report, not codeunits) to get the filter to stick and use the right no. series. Thanks for the schooling on CHANGECOMPANY!kind of fell into this...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
