How to catch event of add or update of 'Item Ledger Entry ' table ?

How to catch event of add or update of 'Item Ledger Entry ' table ?

This question is answered

Hi expert ,

    I  have added one column (UpdateFlag)  in table Item . Now i want to update this column by 'U' when insert or update of quantity in ledger entry table . Please any one tell me how can i catch this event and write code for update column ?

Thanks

Surajit

Verified Answer
  • Hi Jens,

     Thanks a lot .I have added my code in CU(22)   InsertItemLedgEntry(). Its working fine.

    Thanks

    Surajit

All Replies
  • Hi Surajit,

    there is something similar already. The Item table has the field "Cost is adjusted" which is always reset when new item ledger entries or value entries or item applications are posted, and set when the adjustment batch has run successfully.

    So, if you want your own field, these are the places to insert your code.

    with best regards

    Jens

  • How do you clear the "u" once you're done looking at the update flag?

    Do you have a function of processing report to reset them?

    else eventually they will all get filled up.

    I would have focused on "Last Date Modified" or a similar field.

    With a field like this it doesn't require clearing and you can run reports and/or filter a range of dates if you wanted.

  • Hi Jens,

      Thanks for the reply . I can do it on Quantity insert or modify .

    Thanks

    Surajit

  • Hi Jens ,

      I have little bit confusion that how to update my flag

             if i write below code  On 'Item Ledger Entry' quantity   insert / Modify .is it wright code ? yes then how to get ItemNo value

                Item.SetCurrentkey("Item No.",ItemNo);

                Item.SETRANGE("UpdateFlag",TRUE);

    Thanks

    Surajit

  • Hi Surajit,

    I'm afraid it's a little more complicated than this. As Erik Ernst points out here, it is important to know the business logic behind the tables. This defines where your addition to the business logic has to be fitted.

    You want to get a notifier when the item shifts or (possibly) changes its value.

    The inventory of an item lives in the Item Ledger Entries table. Ledger entries are never inserted/modified/deleted directly in a form or page. So, putting code on the quantity field of the entry wouldn't have the desired effect. They will be created by a posting process, always utilizing T83 (Item Journal Line) and CU 22 (Item Jnl. - Post Line). So you could add your code in there, preferably in InsertItemLedgEntry(). When you also need a notification when the value changes (or something happens that needs a re-calculation of the value), then you also need to consider the Value Entries (T5802) and Item Application Entries (T339). Looking at this, you'll notice it's quite a lot of complicated code. For the Adjust Cost Item Entries batch job, NAV also needs a handle to know which items need to be adjusted. As I wrote in my previous post, this flag has at least a similar property like what you require. A quick search with Stati-Cal Prism shows the occurrences of this flag in NAV. So, that's where you need to put your code in.

    with best regards

    Jens

  • Hi Jens,

     Thanks a lot .I have added my code in CU(22)   InsertItemLedgEntry(). Its working fine.

    Thanks

    Surajit