web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

NAV2015 - Adding custom code to OnDatabaseInsert/Modify/Delete/Rename

(0) ShareShare
ReportReport
Posted on by 2,245

Hello gentlemen,

I've been trying to add some custom code to Codeunit 1, the functions OnDatabaseInsert, OnDatabaseModify, OnDatabaseDelete and OnDatabaseRename and I have been failing :( 

For some reason that code does not seems to be executing when as a user, modify data on a page without anything special in it. Like changing the name of a customer. 

I have tried to simplify so I would get a simple message box, or create a new record in a new table, but neither did the trick. 

I need to add code there to perform some data checking between NAV companies and that code is working in previous versions, but apparently not in NAV2015 for some reason.

Any ideas would be highly appreciated.

Regards,

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Jan Veenendaal Profile Picture
    510 on at

    You need to set up the tables/fields that will use the triggers; look in codeunit 5150 Integration Management, function GetDatabaseTableTriggerSetup

    In NAV2016 you shoud use events for this :)

  • jcastro Profile Picture
    2,245 on at

    Hello Jan,

    Thank you for your response.

    I'm unclear as to how this works. I checked the code but in that codeunit, it requires the "enable connector" in the marketing setup to be checked. Which is something I do not wish to enable.

    Leaving that aside, I saw that it checks for some specific tables (customer, resources, etc) and some child tables (sales line for instance). I tried the simple example of changing a customer name and still did not work. I do not see how it could though.

    I am probably missing something, but I fail to see what :-)

  • Suggested answer
    Jan Veenendaal Profile Picture
    510 on at

    The function I mentioned is called from function  GetDatabaseTableTriggerSetup in Codeunit 1.

    In that function there are 4 boolean variables ( OnDatabaseInsert, OnDatabaseModify, OnDatabaseDelete, OnDatabaseRename )  that need to be set to TRUE to enable the execution of the triggers with the same names.

    What you can do is write some code in that function to set one (or more) of these booleans to TRUE just for the cases that you need to check. [ I think you should call a function in a custom codeunit, using VAR parameters - just like the Integration Management codeunit does ]

  • Verified answer
    keoma Profile Picture
    32,729 on at

    hi jose,

    it seems that these triggers are not meant for general usage but for debugging/modifying data, when exchanging data via dynamics connector. then the activated "enable connector" flag activates the whole integration management system.

    in your case - you do not want to set that flag - best edit cu 423 change log management and do some changes in function GetDatabaseTableTriggerSetup.

    IF TableID IN

      [DATABASE::User,

       DATABASE::"User Property",

       DATABASE::"Access Control",

       DATABASE::"Permission Set",

       DATABASE::Permission,

       DATABASE::"Change Log Setup",

       DATABASE::"Change Log Setup (Table)",

       // start changes

       18,27,36,37,279,280, // add the table nos. you want to trigger

       // end changes

       DATABASE::"Change Log Setup (Field)"]

    THEN BEGIN

     LogInsert := TRUE;

     LogModify := TRUE;

     LogDelete := TRUE;

     LogRename := TRUE;

     EXIT;

    END;

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans