No series in copy customer report

I have created a report for copying the customer from one company to another company. In New Customer field i want the last no used for customer no series of the company in which the customer will be copy.

  • Setup the No. Series, enter the last used no. , see below snap

  • In reply to Binesh Singh Rajput:

    i want the last no used in my report.
  • In reply to Seemab07:

    Hello,

    See i wrote a function that can take No.Series Code and return the LastUsed No.

    In function NoSeries and NoSeriesLine are record variable of table 308 and 309.

     

     

    For Testing Call this function something like:

    MESSAGE('Last Used no.: %1', GetLastNoFromNoSeries('CUST'));

  • In reply to Seemab07:

    What i suggested you do same thing, write a function that i given you and then Call GetLastNoFromNoSeries function After Cust.CHANGECOMAPNY(Comp);

    NewCust := GetLastNoFromNoSeries('CUST');
  • In reply to Binesh Singh Rajput:

    what variables u selected in GetLastNoFromNoSeries function.
  • In reply to Seemab07:

    Open no. series page and check what is the code for your customer no. series, that code you have to pass in single code.
    in demo database CUST that is default.
  • In reply to Binesh Singh Rajput:

    i am confused.
  • In reply to Seemab07:

    open Role Center Client -> In Search Menu type No. Series and then No Series Page ->  A no. series page will display,

    -> now Find your Customer Record and copy the Code value.

    see below screenshot.

  • In reply to Seemab07:

    You're trying to look up the last or next number in a number series in a different company. That is not as easy as it sounds. It's not enough to use CHANGECOMPANY and then just call the GetNextNo function. The CHANGECOMPANY is local for the record for which you change it.

    I did it once, where we had a "global no. series" to manage and a assign. In our case a global order no. we had to assign to all orders created in every company. What we found to be the "easiest" and most robust way, was to create a copy of codeunit 396 (NoSeriesManagement) and add a CompanyName parameter to the functions we needed. Here we used CHANGECOMPANY. That was in NAV 3.70.

    Since NAV 2009 we have had Web Services. If I had the same requirement now, then it might just be easier to create a new code which would publish a codeunit which would return the last/next number. And then call the same web service from another NAV codeunit. If you just need to get the last no. then the GetNextNo function is really the only function that needs to be "public".

    And when that has been said about number series, then just using CHANGECOMPANY and COPY to insert customers in a different company, is just as dangerous. The no. series is just one issue. Every field on the customer, where there is a relationship to a different table, then you risk that the related record does not exists. You really need to think very carefully about how you handle errors and verifies the data.

    In my current project, we don't copy customers or sales orders. But we have a global chart of accounts. This is maintained in a master data company. And whenever our global finance department creates a new G/L account, then they run a job to synchronize their changes. We are using a "master data management" add-on for NAV for this. Not only does it give us full tractability over all updates, but it also allows us to synchronized any related data, like new posting groups (incl. their setup). Compared to how much it would take to program similar functionality, then this was much cheaper. I've tried both.

    CHANGECOMPANY is basically only useful for simple lookups or very simple updates.
Related