How to Update Primary Key Item Code in Item Card

selece28selece28 Member Posts: 316
Hi All,
I'm having problems. My client want to update their Item Code in Item Card.
I know i can do Rename from Item Card and Nav wil automatically update the other related table. But If i get a csv file and want to update by script, Is is possible to do?
How is the best way to do it?

I'm thinking of copy All records to one temp table, deleteall records in Item table, then insert again from temp table to Item table with new item code.
But if i do this then nav won't automatically update the related table?

Help me please,
Thanks in advance
______________

Regards,
Steven

Comments

  • kinekine Member Posts: 12,562
    You need to use RENAME function to change the PK of the record.

    And yes, if you will do the DELETE/INSERT the relations will not be updated!
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ara3nara3n Member Posts: 9,255
    Also I would write the dataport like this.

    If item.get(Column[1]) then begin
    item.rename(Column2);
    commit;
    end;

    this will be a long process at least if you cancel you don't have to role back.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • selece28selece28 Member Posts: 316
    Just want to make sure. Is the Rename function can update all related fields? Like sales price, Item UOM, etc?

    Thanks in advance
    ______________

    Regards,
    Steven
  • kinekine Member Posts: 12,562
    Yes
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • selece28selece28 Member Posts: 316
    Opps, i think cannot do this way.
    I try using 10 items, i took so long.
    How about if i delete table Item, Item UOM, Sales Price, and Item Ledger Entry.
    Then i import(INSERT) the item again using dataport. Can i do this way?
    When inserting the Item, i also insert the Item UOM.
    Then import the item ledger entry and sales price.
    Because my client want to have a clean DB for the year.

    Is there any other table beside Item UOM, Sales Price and Item ledger entry that have relation to Item Table?

    Thanks in advance
    ______________

    Regards,
    Steven
  • kinekine Member Posts: 12,562
    Many tables has this relation... all sales and purchase documents, value entries, transfers, service module, manufacturing... NAV is working with Items everywhere - it is why it took so long time...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • selece28selece28 Member Posts: 316
    Wow so many tables.
    I'm thinking of creating a new DB for them, so i just import the new Item Card, and the Sales Price table. Also Import opening Inventory balance.
    I think this is the safest way.

    Any comments or suggestion?

    Thanks in advance
    ______________

    Regards,
    Steven
Sign In or Register to comment.