Options

Accidently Deleted Items with Ledger entries

whighsmithwhighsmith Member Posts: 11
Guys I just made a mistake.

I deleted a bunch of old items thinking Navision wouldn't let me delete any item with ledger entries. Now I realise I was wrong. I deleted about 266 items that had ledger entries.

Because I often report off the ledger entry & value entry tables, I would really like to restore this data.

I have all info in a backup database.
Is it possible to restore all information from these items as if I had not deleted them?

Thanks so much for the help!

Comments

  • Options
    mukshamuksha Member Posts: 274
    My dear friend,
    Now you can do only one thing that insert the ledger enters manually with the same no. very carefully. If you follow any other process that may have some other impacts.
    Mukesh Sharma
  • Options
    ara3nara3n Member Posts: 9,255
    hello. When you delete an item that has entries in closed accounting period, Navision does not delete the value and item ledger entries. It simply blanks the Item no.

    So what you need to do is restore the back in a separate database. copy and past the items that you want to restore. Then write a routine to fill the item not in value entry and item ledger entry.

    You can still run your reports on the ledger. it just that the item will be blank.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    Alex_ChowAlex_Chow Member Posts: 5,063
    ara3n wrote:
    hello. When you delete an item that has entries in closed accounting period, Navision does not delete the value and item ledger entries. It simply blanks the Item no.

    So what you need to do is restore the back in a separate database. copy and past the items that you want to restore. Then write a routine to fill the item not in value entry and item ledger entry.

    You can still run your reports on the ledger. it just that the item will be blank.

    Basically, if you run your reports based on item will not match the reports based on customers if the item ledger has blank item numbers on the item ledger.

    It's okay so long as the customers understand the consequences.
  • Options
    SavatageSavatage Member Posts: 7,142
    If I try that I get a message about "legder entries existing" unless they are years old and everything is closed.
  • Options
    kinekine Member Posts: 12,562
    In which way was the items deleted? Through some custom code? Or by pressing Delete or F4? (I want to know if the OnDelete trigger was called or not, if not, you just needs to re-create the item records and not the ledger entries).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    David_CoxDavid_Cox Member Posts: 509
    Use the information on the Item Ledger and Value entries to recreate your items, this sample code is a guide and not complete or tested.

    Create a simple report on the item ledger entry, Group this by "Item No.", give this report any table permissions required.

    Create a function in the report called CheckItem with a local variables, Item type Record, Value Entry type record, and any other tables like Item unit of Measure etc:, and on the group header or footer call the function after the standard code.
    IF CurrReport.SHOWOUTPUT THEN
        CheckItem();
    
    CheckItem()
    IF NOT Item.GET("Item Ledger Entry"."Item No.")THEN BEGIN
        Item.INIT;
        Item."No." := "Item Ledger Entry"."Item No.";
        Item.Description := "Item Ledger Entry".Description;
        ValueEntry.RESET;
        ValueEntry.SETCURRENTKEY("Item Ledger Entry No.");
        ValueEntry.SETRANGE("Item Ledger Entry No.","Item Ledger Entry","Entry No.");
        IF ValueEntry.FINDFIRST THEN 
           Item."Inventory Posting Group" := ValueEntry."Inventory Posting Group";
        
       //Add new code to Insert UOM table
       
       //Add new code to Insert Dimensions from Ledger Entry Dimension Table
       
       Item.INSERT;
    END;
    

    Add code to insert the units of measure from the values in the Item Ledger, or value entry, also from the item ledger you may be able to get the dimensions, and other static information.
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • Options
    David_CoxDavid_Cox Member Posts: 509
    If you have an old backup, you could also restore this as a stand alone, you know the criteria for the Items you deleted, create some dataports and Export the records, then Import them back into your live database this will recreate any lost records, but you would loose any changes.

    Items as required
    All Default Dimensions for Table 27 Item

    Tables you would need to export all records for.
    Item Unit Of Measure

    And if required
    Item Bill of Materials
    Purchase and Sales Prices
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • Options
    whighsmithwhighsmith Member Posts: 11
    kine wrote:
    In which way was the items deleted? Through some custom code? Or by pressing Delete or F4? (I want to know if the OnDelete trigger was called or not, if not, you just needs to re-create the item records and not the ledger entries).

    Yes I deleted using F4.

    Thanks for all the help everyone!
Sign In or Register to comment.