---
title: "HowTo Implement Source Control in MS Dynamics NAV"
description: "HowTo Implement Source Control in MS Dynamics NAV"
keywords: "HowTo Implement Source Control in MS Dynamics NAV"
url: "https://myrapidi.com/wiki/howto_implement_source_control_in_ms_dynamics_nav"
locale: "en"
published: "2009-06-08T17:32:50Z"
modified: "2021-06-17T11:17:12Z"
---

## Overview

- 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.&nbsp;
- Source Control is a field ?&nbsp; a number in succession ?&nbsp; 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).&nbsp;
- 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".&nbsp;
- Add a new key to the table containing just the "SourceCounter" field.&nbsp;
- Add the following Source Control code in "SourceCounter ?&nbsp; OnValidate".&nbsp;

> | _IF Customer2.SETCURRENTKEY(SourceCounter) THEN BEGIN  
> &nbsp;&nbsp;&nbsp; Res := Customer2.FIND('+');  
> &nbsp;&nbsp;&nbsp; SourceCounter := Customer2.SourceCounter + 1;  
> END;_ |

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

- 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](https://myrapidi.com/wiki/read_design.md)" on the MS Dynamics NAV DataSource (go to Configure, MS Dynamics NAV in the Rapidi configuration to do this)&nbsp;
- Edit&nbsp;the Transfer where you need to use the Source Control and unfold the Source Control section. enter "SourceCounter" in the "Source Control Field".

&nbsp;

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.

&nbsp;
