Changing the Customer No. from alpanumeric to numeric

drevelldrevell Member Posts: 7
edited 2003-06-24 in Navision Attain
I am having a hard time finding a automated way to rename the customer No. and having it cascade the changes down through the other tables that the Customer No. is written in. (i.e. the sales invoice header, etc.) Has anyone had to do this? If so could you share the solution.

David E. Revell :)

Comments

  • bruno77bruno77 Member Posts: 62
    Hi,

    The RENAME function should work:

    RENAME (Record)
    Use this function to change a primary key in a C/SIDE table.

    RENAME will select the best key (index) available when renaming linked records.

    Regards,

    Bruno
  • YUHYUH Member Posts: 3
    bruno77 wrote:
    Hi,

    The RENAME function should work:
    ...
    Bruno

    I think, It is important to add that the cascade rename works only for the fields with proper TableRelation property set.
    Regards, YUH
  • drevelldrevell Member Posts: 7
    I tried to use the:
    Customer.RENAME(Customer."No.");
    and it doesn't rename the Customer No's
  • YUHYUH Member Posts: 3
    drevell wrote:
    I tried to use the:
    Customer.RENAME(Customer."No.");
    and it doesn't rename the Customer No's

    Hi,
    first you should locate the record you would like to rename. Then provide a new value(s) of primary key field(s) to the RENAME command. The example could be:

    Cust.GET('10000');
    Cust.RENAME('123456');
    ...or...
    Cust.FIND('-');
    Cust.RENAME('NEW' + Cust."No.");

    But! This would not work:

    Cust."No." := 'NEW' + Cust."No.";
    Cust.RENAME(Cust."No.");
    Regards, YUH
  • drevelldrevell Member Posts: 7
    Thanks for that help; but I'm trying to loop through all the records (customers) and rename each to the new default No. Series that I've defined (C-Cust 1-99999999). I'd like to do this without having to define a report to look for each customer name but instead loop through and then rename it to the Last No. Used. Any thoughts?

    Thanks in advance for the help

    David Revell
  • borsicsjborsicsj Member Posts: 32
    Hi,
    be careful doing that. You can easily create a neverending loop if you use the primary key. Try to save the original customer nos into a new field, than create a new key on this field. Than use the newly created key to renumber the records. I had some problems when i was renumbering fixed assets.
    Brg,

    --
    János Borsics
  • SunsetSunset Member Posts: 201
    You can use a report that cycles through all the customers and have a variable defined as customer and rename the variable.

    So something like this:

    Customer

    "OnAfterGetRecord"

    VarCust := Customer;
    varCust.No := NoSeriesMgt.GetNextNo(NoSeriesCode, SeriesDate, ModifySeries)
    varcust.rename(varcust.no);
    Don't just take my word for it, test it yourself
  • drevelldrevell Member Posts: 7
    I got a report with the following code to work, but it is very slow with our 3000 customer list. Does anyone know how to speed this up?

    "Customer No. Old" := "No.";
    SalesSetup.GET;
    CLEAR(NewNo);
    NoSeriesMgt.InitSeries(SalesSetup."Customer Nos.",SalesSetup."Customer Nos.",0D,NewNo,SalesSetup."Customer Nos.");
    RENAME(NewNo);

    Variables

    Name DataType Subtype Length
    NoSeriesMgt Codeunit NoSeriesManagement
    SalesSetup Record Sales & Receivables Setup
    NewNo Code 20
  • SunsetSunset Member Posts: 201
    A couple of things:

    1. Don't get the salessetup every time. Do it on PreDataItem, the code is not going to change.
    2. NoSeriesMgt.InitSeries calls NoSeriesMgt.GetNextNo so you don't need that. Do a "varCust.No := NoSeriesMgt.GetNextNo(salessetup.NoSeriesCode, 0d, true);"
    3. As rename cascades through all values that link to Customer.No it is always going to be slow. So if you need to do it in a limited amount of time, you'll have to split the job using filters.
    Don't just take my word for it, test it yourself
Sign In or Register to comment.