Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

In which codeunit i can write code when any insert / Modify for in NAV tables ?

Posted on by 975

Hi expert ,

   Can any one give me any document from which i can know that which tables are used which codeunit ? I want to write my code for main tain a update flag for (Items / Customer / Shipping Address / Sales  Price / Sales line Discount ) tables which  will be Inserted / Updated?

Thanks in Advance

Surajit

*This post is locked for comments

  • Suggested answer
    Jens Glathe Profile Picture
    Jens Glathe 6,092 on at
    RE: In which codeunit i can write code when any insert / Modify for in NAV tables ?

    Hi Surajit,

    in addition to the answers already given (especially Ben's), please be aware that there is a major difference what the cause of the modification is. If anything is entererd by GUI and the normal table triggers are used, then you have several options, where putting the code into the OnInsert/OnModify/OnDelete trigger of the table might be feasible. However, when the changes are done by code (running an update batch, an xmlport without using modify(true), various other possible sources), then you have only one trigger inside NAV: The OnDatabaseInsert/Modify/Delete functions in CU 1. But as Ben said, be careful, this can have a major impact on performance.

    with best regards

    Jens

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,135 Super User 2024 Season 2 on at
    RE: In which codeunit i can write code when any insert / Modify for in NAV tables ?

    You need to use Object Manager tool of Idyn.

    Google it.you will find more info.

  • Andri Wianto Profile Picture
    Andri Wianto 385 on at
    RE: In which codeunit i can write code when any insert / Modify for in NAV tables ?

    Run the Debugger, and see what you are looking for. All of them you are looking for is there.

  • Benoit Delvaux Profile Picture
    Benoit Delvaux 870 on at
    RE: In which codeunit i can write code when any insert / Modify for in NAV tables ?

    So you want to log values un a third-party table each time data is Inserted / Modified in a NAV table like Item, Customers, Shipping addresses etc?

    Then you just need to put your code in the OnInsert / OnModify trigger of each Table.

    Each table in NAV has OnModify/OnInsert/OnDelete trigger.

    If you want to log for a specific field then you need to put your code in the OnValidate trigger of that field.

    If you want to create kind of more generic logging system then you can analyze the CodeUnit 1 ApplicationManagement which contains more global triggers like OnDatabaseInsert for example which is fired each time something is inserted regardless of the table. (but be careful as it is a core codeuinit of Nav and each change should be thouroughly analyzed)

    Regards,

  • surajitkundu Profile Picture
    surajitkundu 975 on at
    RE: In which codeunit i can write code when any insert / Modify for in NAV tables ?

    Hi expert ,

     Please give me a suggestion .

    thanks

    Surajit

  • surajitkundu Profile Picture
    surajitkundu 975 on at
    RE: In which codeunit i can write code when any insert / Modify for in NAV tables ?

    Hi Benoit ,

     Thanks for the reply . Actually I have maintain a udf column ('UpdateFlag') for those above tables . I want to update this flag by 'F' value when data are inserted /Updated in above those tables . I have write code for example of item table :

                                   Item.GET("Item No.");

                                   Item.UpdateFlag := 'F';

                                   Item.MODIFY;

       But I can't understand where the above code is placed for the above those tables.Have you any document where I can see which tables(Items / Customer / Shipping Address / Sales  Price / Sales line Discount )  use codeunit  for Insert/Update ?

    Thanks

    Surajit

  • Benoit Delvaux Profile Picture
    Benoit Delvaux 870 on at
    RE: In which codeunit i can write code when any insert / Modify for in NAV tables ?

    Hi,

    If the purpose is to have a log of insertions, deletions & modifications you can easily set it up from the Change Log Setup page.

    Hope it helps...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans