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
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...
Answers
InitSeries Call a function called GetNextNo.
GetNextNo uses VALIDATION :-(
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
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?
I would probably duplicate the code into a new function with a company name parameter, much like an overload.
RIS Plus, LLC
DenSter comment is the way to go.
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
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!