Search our Wiki

HowTo Implement Source Control in MS Dynamics NAV


  • If you want to transfer only the records that have been changed since the last transfer, you can make use of the feature, Source Control. 
  • Source Control is a field ?  a number in succession ?  that must be updated whenever a record is inserted and/or updated. The field is created in the table that you want to transfer data from (the Source Table). 
  • You only need to add this field and code if your MS Dynamics NAV is running on a native or C/Side database. When MS Dynamics NAV is running on SQL database, we can use the timestamp field in the SQL table instead.

Add Source Control Field in MS Dynamics NAV

To add the Source Control functionality to a table, follow the following steps:

  • In the table that should use Source Control, create a new field called "SourceCounter" with data type "BigInteger". 
  • Add a new key to the table containing just the "SourceCounter" field. 
  • Add the following Source Control code in "SourceCounter ?  OnValidate". 
    Res := Customer2.FIND('+');
    SourceCounter := Customer2.SourceCounter + 1;

PLEASE NOTE: The above code is an example of applying Source Control in the customer table (you need to create a variable called "Customer2" that refers to the table Customer, and a boolean variable called "Res"). 

  • Call the above code with VALIDATE (like VALIDATE("SourceCounter"); ) where records from this table are modified and inserted. This includes the OnCreate and the OnModify triggers on the table itself.
  • Since you have changed the design by creating a new field you need to do "Read Design" on the MS Dynamics NAV DataSource (go to Configure, MS Dynamics NAV in the Rapidi configuration to do this) 
  • Edit the Transfer where you need to use the Source Control and unfold the Source Control section. enter "SourceCounter" in the "Source Control Field".


That is it - now all that's left is to test that it works. Verify that when you edit or create a record in your table, the SourceCounter field gets updated. It should contain the highest value of all SourceCounter values across the whole table.