When is value changed in DB


I’m on NAV2009 R2 and tries to sync changes on Item to a third-party system. I having code in table 27 in the OnModify-Trigger. Problem is that I am executing a third-party program via schell-command in the onmodify-trigger in table 27 which is getting the item from SQL-server but the value is not changed in db until I leaves the form in NAV so the value in DB seems to be the xRec until I get the next record in NAV.

Where should I place my code to get the correct value from DB?

So you have code directly on the OnModify trigger, that should update the external system?

In NAV the changes are NOT committed to SQL, until the transaction is complete. From the page, that is when the user either closes the page, or moves to the next record.

I would never put such a code directly on the OnModify trigger. Not only will it slow down the actual user experience, but you will also risk, that the process exits before committing (worst case).

So if you need to synchronize a different system, then I would do that part in batch mode. I.e. by checking all records and the uploading the changed.

Ok so the changes are committed only when the transaction is complete. I see.

The program that is executed on the onmodify-trigger is silent so it will not interfere with the user experience.

How do you mean by “checking all records”?

Maybe I can run the external program and check item - table for items that have the “last date modified” - field = todaysdate. Would this be a good solution?

By “checking all the records” then I would implement a sort of “time-stamp” (this is actually part of the new functionality in NAV 2016). But as an alternative then “last date modified” could be used, although I would go for a DateTime field, rather than a Date field.

Or you could use the OnModify/OnInsert/OnDelete/OnRename triggers to insert a record into a “sync queue” table (basically just the primary key, the action and the datetime). Then if the actual transaction is aborted, then the sync queue table record is also aborted. So no harm done. I have even seen someone who did this using the standard change log tables in NAV.

Ok good info.

I will create a sync table and insert the changed items there. And then remove them from sync table when they are synced.