<Solved> OnDatabaseModify trigger does not fire for PurchaseLine Table

jordi79jordi79 Member Posts: 277
edited 2019-09-04 in NAV Three Tier
Hi,
This test is done in Std Cronus, NAV2018 11.0.26893 .

1) In Codeunit1, function OnDatabaseModify, I put a breakpoint here.
2) Then I turn on the debugger
3) When I modify a record SalesLine table (Modified from table directly, not from Page), the debugger breaks on the OnDatabaseModify function
GREAT!!!

4) However when I modify a record in PurchseLine table (Modified from table directly, not from Page), the debugger DOES NOT break on the OnDatabaseModify function
NOT GREAT!!!

Why is it that changes in PurchaseLine table does not trigger OnDatabaseModify trigger?

I have also tested with other table such as Customer, Payment Terms, currency, and these tables fire the OnDatabaseModify function. But this does not seem to work on PurchaseLine.

Jordi


Comments

  • aacnsilvaaacnsilva Member Posts: 23
    You're probably facing a weird bug.
    Try to close the debugger and development environment, open it again and re-do your test.

    The OnDatabaseModify trigger should run whenever there is a change to any record.
  • jordi79jordi79 Member Posts: 277
    I tested in 2 different version (NAV2017 and NAV2018), and the outcome is the same.

    However, there is a workaround. Turn on change log for PurchLine table, and the OnDatabaseModify trigger will fire.
  • aacnsilvaaacnsilva Member Posts: 23
    jordi79 wrote: »
    I tested in 2 different version (NAV2017 and NAV2018), and the outcome is the same.

    However, there is a workaround. Turn on change log for PurchLine table, and the OnDatabaseModify trigger will fire.

    It'll fire but you validated that it didn't just fire because of the Change Log record?
  • krikikriki Member, Moderator Posts: 9,115
    You first need to enable the database trigger by running function "GetDatabaseTableTriggerSetup" and telling the system that T39 should be enabled.

    This function will ONLY run once per session when the table is first accessed. So once you have the code in place that calls the function "GetDatabaseTableTriggerSetup", you need to restart your client.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • aacnsilvaaacnsilva Member Posts: 23
    kriki wrote: »
    You first need to enable the database trigger by running function "GetDatabaseTableTriggerSetup" and telling the system that T39 should be enabled.

    This function will ONLY run once per session when the table is first accessed. So once you have the code in place that calls the function "GetDatabaseTableTriggerSetup", you need to restart your client.

    @kriki is right. I was wrong, the OnDatabaseModify trigger does not run in every single record, it only runs on the ones that are defined like @kriki said.
    I suggest you to read this article, and focus on deV.ch's answer: https://forum.mibuso.com/discussion/59929/cu-1-ondatabase-methods
  • jordi79jordi79 Member Posts: 277
    kriki wrote: »
    You first need to enable the database trigger by running function "GetDatabaseTableTriggerSetup" and telling the system that T39 should be enabled.

    This function will ONLY run once per session when the table is first accessed. So once you have the code in place that calls the function "GetDatabaseTableTriggerSetup", you need to restart your client.

    This the solution. You either modify this function to include the table you want to fire Database triggers, or just simple enable it in changelog.

    Thanks.
Sign In or Register to comment.