Trigger that gets also called by simple modify

Hello.

I'm using NAV in a three company setup and want to sync table data to my other companies. Therefore I've created a simple CU that inserts/updates preselected tables in the other company. I want to call this method everytime when a record in the company was inserted or modified. Therefore I rely on the OnInsert and OnModify trigger of the tables (e.g. Item table). My problem is that there are many code lines (even in the standard NAV Ca/L) that make modifications and inserts without passing TRUE and therefore calling the triggers. I have also tried to use GlobalOnModify in CU 1 with the same results. Is there a way to get notified of all inserts/updates?

Best Answer

  • vaprogvaprog Member Posts: 1,140
    Answer ✓
    There are two sets of triggers in Codeunit 1:

    OnGlobal... with IDs 20..24
    OnDatabase... with IDs 25..29

    The former set is called whenever the corresponding table trigger is called also.

    The latter set is new with NAV 2009 R2 and is called whenever a corresponding action is carried out on a table.

Answers

  • Wisa123Wisa123 Member Posts: 308
    Hi,

    If you really need to instantly sync the tables as soon as something happens, i think the only real way is a Insert Trigger on the SQL Tables directly. I may be wrong on this though, however preventing a lot of locking may be a challenge.

    However if you dont need the data instantly, i would just create a scheduled Report to do the job over night (or be called manually).

    regards, wisa
    Austrian NAV/BC Dev
  • gin31gin31 Member Posts: 2
    edited 2016-01-18
    Yikes, this is what I was afraid of.. Yes, I need the data instantly. I don't really want to put any logic inside a database trigger. Hm, is there a way to call a CU from the database trigger, so that I can handle the logic inside NAV?
  • vaprogvaprog Member Posts: 1,140
    Answer ✓
    There are two sets of triggers in Codeunit 1:

    OnGlobal... with IDs 20..24
    OnDatabase... with IDs 25..29

    The former set is called whenever the corresponding table trigger is called also.

    The latter set is new with NAV 2009 R2 and is called whenever a corresponding action is carried out on a table.
Sign In or Register to comment.