<turbo-stream action="update" target="wiki_card"><template>
<h1>HowTo Implement Source Control in MS Dynamics NAV</h1>
<h2>Overview</h2>
<ul>
<li>If you want to transfer only the records that have been changed since the last trans<span>fer, you can make use of the feature, Source Control.&nbsp;</span></li>
<li><span>Source Control is a field ?&nbsp; a number in succession ?&nbsp; that must be updated when<span>ever a record is inserted and/or updated. The field is created in the table that you want to transfer data from<span> (the Source Table).&nbsp;</span></span></span></li>
<li>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.</li>
</ul>
<h2>Add Source Control Field in MS Dynamics NAV</h2>
<p>To add the Source Control functionality to a table, follow the following steps:</p>
<ul>
<li><span>In the table that should use Source Control, create a new field called<span> "<span>SourceCounter" with data type "BigInteger".<span>&nbsp;</span></span></span></span></li>
<li><span>Add a new key to the table containing just the "SourceCounter" field.<span>&nbsp;</span></span></li>
<li><span>Add the following Source Control code in "SourceCounter ?&nbsp; OnValidate".<span>&nbsp;</span></span></li>
</ul>
<blockquote>
<table border="0">
<tbody>
<tr>
<td><em>IF Customer2.SETCURRENTKEY(SourceCounter) THEN BEGIN<br>&nbsp;&nbsp;&nbsp; Res := Customer2.FIND('+');<br>&nbsp;&nbsp;&nbsp; SourceCounter := Customer2.SourceCounter + 1;<br>END;</em></td>
</tr>
</tbody>
</table>
</blockquote>
<blockquote>
<p><strong>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;</strong></p>
</blockquote>
<ul>
<li><span>Call the above c<span><span>ode 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.</span></span></span></li>
<li><span>Since you have changed the design by creating a new field you need to do "<a href="/wiki/read_design" data-turbo="true" data-turbo-stream="true" data-controller="wiki" data-action="wiki#updateUrl">Read Design</a>" on the MS Dynamics NAV DataSource (go to Configure, MS Dynamics NAV in the Rapidi configuration to do this)<span>&nbsp;</span></span></li>
<li><span><span>Edit</span>&nbsp;the Transfer where you need to use the Source Control and unfold the Source Control section. enter "SourceCounter" in the "Source Control Field".</span></li>
</ul>
<p>&nbsp;</p>
<p>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.</p>
<p>&nbsp;</p>
</template></turbo-stream>

<turbo-stream action="replace" target="meta_description"><template><meta content='HowTo Implement Source Control in MS Dynamics NAV' id='meta_description' name='description'></template></turbo-stream>
<turbo-stream action="replace" target="meta_keywords"><template><meta content='HowTo Implement Source Control in MS Dynamics NAV' id='meta_keywords' name='keywords'></template></turbo-stream>
<turbo-stream action="update" target="meta_title"><template>HowTo Implement Source Control in MS Dynamics NAV - MyRapidi Wiki</template></turbo-stream>
<turbo-stream action="prepend" target="flash"><template></template></turbo-stream>
