deploy: 9e06f72056
This commit is contained in:
parent
de09820554
commit
e4f08bf9a7
187 changed files with 6620 additions and 6342 deletions
|
|
@ -5,16 +5,16 @@
|
|||
<meta name=generator content="Hugo 0.92.1">
|
||||
<meta name=description content>
|
||||
<title>Surrogate keys using Autoincrement Pattern :: AL Guidelines</title>
|
||||
<link href=/css/nucleus.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/fontawesome-all.min.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/featherlight.min.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/perfect-scrollbar.min.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/auto-complete.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/theme.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/theme-blue.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/variant.css?1644506468 rel=stylesheet>
|
||||
<link href=/css/print.css?1644506468 rel=stylesheet media=print>
|
||||
<script src=/js/jquery.min.js?1644506468></script>
|
||||
<link href=/css/nucleus.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/fontawesome-all.min.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/featherlight.min.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/perfect-scrollbar.min.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/auto-complete.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/theme.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/theme-blue.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/variant.css?1644600599 rel=stylesheet>
|
||||
<link href=/css/print.css?1644600599 rel=stylesheet media=print>
|
||||
<script src=/js/jquery.min.js?1644600599></script>
|
||||
<style>:root #header+#content>#left>#rlblock_left{display:none!important}</style>
|
||||
</head>
|
||||
<body data-url=/navpatterns/1-patterns/implementation-of-surrogate-keys-using-autoincrement-pattern/>
|
||||
|
|
@ -32,9 +32,9 @@ ALGuidelines.Dev
|
|||
<input data-search-input id=search-by type=search placeholder=Search...>
|
||||
<span data-search-clear><i class="fas fa-times"></i></span>
|
||||
</div>
|
||||
<script src=/js/lunr.min.js?1644506468></script>
|
||||
<script src=/js/auto-complete.js?1644506468></script>
|
||||
<script src=/js/search.js?1644506468></script>
|
||||
<script src=/js/lunr.min.js?1644600599></script>
|
||||
<script src=/js/auto-complete.js?1644600599></script>
|
||||
<script src=/js/search.js?1644600599></script>
|
||||
</div>
|
||||
<div class=highlightable>
|
||||
<ul class=topics>
|
||||
|
|
@ -248,14 +248,14 @@ ALGuidelines.Dev
|
|||
<div class=wrapper>
|
||||
<nav id=TableOfContents>
|
||||
<ul>
|
||||
<li><a href=#abstract><strong>Abstract</strong></a></li>
|
||||
<li><a href=#description><strong>Description</strong></a></li>
|
||||
<li><a href=#usage><strong>Usage</strong></a></li>
|
||||
<li><a href=#abstract>Abstract</a></li>
|
||||
<li><a href=#description>Description</a></li>
|
||||
<li><a href=#usage>Usage</a></li>
|
||||
<li><a href=#nav-specific-example><strong>NAV Specific Example</strong></a></li>
|
||||
<li><a href=#nav-usages><strong>NAV Usages</strong></a></li>
|
||||
<li><a href=#ideas-for-improvement><strong>Ideas for improvement</strong></a></li>
|
||||
<li><a href=#consequences-when-it-should-not-be-used><strong>Consequences (When it should not be used)</strong></a></li>
|
||||
<li><a href=#related-topics><strong>Related Topics</strong></a></li>
|
||||
<li><a href=#nav-usages>NAV Usages</a></li>
|
||||
<li><a href=#ideas-for-improvement>Ideas for improvement</a></li>
|
||||
<li><a href=#consequences-when-it-should-not-be-used>Consequences (When it should not be used)</a></li>
|
||||
<li><a href=#related-topics>Related Topics</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
|
@ -266,27 +266,24 @@ ALGuidelines.Dev
|
|||
<main id=body-inner>
|
||||
<h1>Surrogate keys using Autoincrement Pattern</h1>
|
||||
<p><em>By <a href=http://mvp.microsoft.com/en-us/mvp/Soren%20Klemmensen-5001002 title="Soren Klemmensen">Soren Klemmensen</a>, <a href=http://partner-ready-software.com/ title=Partner-Ready-Software><em>Partner-Ready-Software</em> </a> & <a href=http://www.360visibility.com/ title="360 Visibility">360 Visibility</a></em></p>
|
||||
<h2 id=abstract><strong>Abstract</strong></h2>
|
||||
<h2 id=abstract>Abstract</h2>
|
||||
<p>This Pattern is meant to create generic & reusable links between tables. The goal is to have an easy generic way to link a generically designed sub table to a record on a main table which can be used for other links too.</p>
|
||||
<p>To minimize the impact of customizations and to keep modules as generic and reusable as possible the idea of the Implementation of surrogate keys using AutoIncrement pattern is:</p>
|
||||
<ul>
|
||||
<li>To create a generic and reusable auto generated link (A Surrogate Key), Immune to natural key data & requirement changes, on a main table with minimum impact on the table.</li>
|
||||
<li>To create generic and reusable sub tables that effortless can be reused anywhere in the application.</li>
|
||||
</ul>
|
||||
<h2 id=description><strong>Description</strong></h2>
|
||||
<h2 id=description>Description</h2>
|
||||
<p>Over years of development many things are repeated across different implementation and even inside the same application. A typical example could be adding comments to an area just as it is done in Microsoft Dynamics NAV multiple times. There can be reasons for doing this again and again, but not only does this need to be maintained and upgraded over the years, but all the implementations of comments also needs to be tested separately. If a standard and generic comment could be developed and a generic way of connecting it to a main table this could be resolved. This is exactly what this pattern is trying accomplish.</p>
|
||||
<p><a href=0458.Figure-1.PNG><img src=0458.Figure-1.PNG alt=" "></a></p>
|
||||
<p><em>Figure 1: Table structure for linking a Document Header and Line Table with a Document Comment Table.</em></p>
|
||||
<p>__</p>
|
||||
<p>_<a href=0638.Figure-2.PNG><img src=0638.Figure-2.PNG alt=" "></a>_</p>
|
||||
<p><a href=0638.Figure-2.PNG><img src=0638.Figure-2.PNG alt=" "></a></p>
|
||||
<p><em>Figure 2: Table Structure for linking a Master Data Table with a Master Data Comment Table</em></p>
|
||||
<p>__</p>
|
||||
<p>A typical way of linking a table to master data or to a document has been to use the primary key of the table being linked to. This causes some issues as the linked table now is designed specifically for the main table and it functionality cannot be reused. In case of renames the linked table needs to be renamed too which is costly in processing. Code also needs to be added on the delete trigger of the table to ensure that the attached records get removed if needed which increases the over all footprint of any change.</p>
|
||||
<p>_<a href=0333.Figure-3.PNG><img src=0333.Figure-3.PNG alt=" "></a>_</p>
|
||||
<p><a href=0333.Figure-3.PNG><img src=0333.Figure-3.PNG alt=" "></a></p>
|
||||
<p><em>Figure 3: A Generic Way of creating a Comment table and linking it in a generic way to the main table no matter what this table might be. The Unique Record Identifier on the main tables is an Integer with AutoIncrement set to yes.</em></p>
|
||||
<p>__</p>
|
||||
<p>It is recommended using this pattern in all tables which need sub tables unless specific reasons exists for not doing this.</p>
|
||||
<h2 id=usage><strong>Usage</strong></h2>
|
||||
<h2 id=usage>Usage</h2>
|
||||
<p><strong>Step 1</strong>: Create a generic Unique Record Identifier in the main table</p>
|
||||
<p>The Pattern is implemented by adding a Field (I have called it Unique Record Identifier for this article) in a table (the main Table) where links are needed to be established to. Set the Property Data Type to Integer, Editable to No & AutoIncrement to Yes.</p>
|
||||
<p><strong>Step 2</strong>: Create a generic link-able sub table.</p>
|
||||
|
|
@ -308,27 +305,20 @@ ALGuidelines.Dev
|
|||
<h2 id=nav-specific-example><strong>NAV Specific Example</strong></h2>
|
||||
<p>Let’s assume we would like to create comment for a larger number of very different tables in the system.</p>
|
||||
<p><strong>Update the Customer table (Step 1)</strong>: Go to table 18 Customer and add Field 50000 Unique Record Identifier. Set the Property Data Type to Integer, Editable to No & AutoIncrement to Yes. Save the changes.</p>
|
||||
<p>_<a href=1488.Example-Figure-1.png><img src=1488.Example-Figure-1.png alt=" "></a>_</p>
|
||||
<p>__</p>
|
||||
<p>_<a href=4682.Example-Figure-2.png><img src=4682.Example-Figure-2.png alt=" "></a>_</p>
|
||||
<p>__</p>
|
||||
<p><a href=1488.Example-Figure-1.png><img src=1488.Example-Figure-1.png alt=" "></a></p>
|
||||
<p>_<a href=4682.Example-Figure-2.png><img src=4682.Example-Figure-2.png alt=" "></a></p>
|
||||
<p><strong>Create Comment table (Step 2)</strong>: Create a new table called Comment. Add 3 fields Table No., Unique Record Identifier & Line No. all of Data Type Integer. Make these 3 fields into the primary key for the table. Add a 4 field called Comment with Data Type Text(80). Save the changes.</p>
|
||||
<p><a href=4532.Example-Figure-3.png><img src=4532.Example-Figure-3.png alt=" "></a></p>
|
||||
<p><strong>Create the Comments page (Step 3)</strong>: Start the page wizard and create a Page based on table comment created above as a List only showing the Comment field. Set AutoSplitKey property to Yes on the page.</p>
|
||||
<p>__</p>
|
||||
<p>_<a href=2068.Example-Figure-4.png><img src=2068.Example-Figure-4.png alt=" "></a>_</p>
|
||||
<p>__</p>
|
||||
<p><strong>Update the Customer Card (Step 4)</strong>: Add an action to the Customer Card to open the Comments. Go to Actions and create an action called Smart Comment. Populate the properties RunObject, RunPageView and RunPageLink as see in the picture below.</p>
|
||||
<p><a href=/cfs-file.ashx/__key/communityserver-wikis-components-files/00-00-00-00-42/0552.Example-Figure-5.png><img src=0552.Example-Figure-5.png alt=" "></a></p>
|
||||
<p>__</p>
|
||||
<p><strong>Create a hook OnDatabaseDelete (Step 5)</strong>:</p>
|
||||
<p>Create a codeunit 50000 called “ApplicationManagement Hook” with one function called OnAfterOnDatabaseDelete taking the parameter RecRef of Data Type RecordRef. Add it as a global variable to Codeunit 1 ApplicationManagement and call the function as the last line in OnDatabaseDelete. Please read about the hook pattern before implementing it.</p>
|
||||
<p><a href=/cfs-file.ashx/__key/communityserver-wikis-components-files/00-00-00-00-42/4477.Example-Figure-6.png><img src=4477.Example-Figure-6.png alt=" "></a></p>
|
||||
<p>__</p>
|
||||
<p><strong>Create the code needed to delete comments linked to a deleted record (Step6)</strong>:</p>
|
||||
<p>Create a DeleteComments function taking the RecRef of Data Type RecordRef and add the code as shown blow.</p>
|
||||
<p><a href=/cfs-file.ashx/__key/communityserver-wikis-components-files/00-00-00-00-42/1884.Example-Figure-7.png><img src=1884.Example-Figure-7.png alt=" "></a></p>
|
||||
<p>__</p>
|
||||
<p>It is assumed in this example for simplicity that the Field 50000 is reserved across the entire application for the Unique Record Identifier as defined in Step 1.</p>
|
||||
<p>The comments are now fully working if we look away from the fact that we did not deal with a few things specific to Sales orders like RecreateSalesLines function, Archiving and Copy Document. All of which can easily be dealt with.</p>
|
||||
<p>These comments are now completely reusable everywhere else in the system. Sales Document is a perfect example as the primary keys of the Sales Header and the Sales line are both different from the customer and normally we would not be able to use the comments header or the line. All that needs to be done is adding the Field 50000 Unique Record Identifier to the Sales Header & Sales Line (Disregarding the posted documents in this example) and creating the actions on the Page Actions with the needed filters. Deletion is already handled of comments no matter what the main table might be.</p>
|
||||
|
|
@ -336,15 +326,14 @@ ALGuidelines.Dev
|
|||
<p>Other ideas for use of this pattern could be. An Error table, Tags, Dynamically defined fields and Generic fact boxes. Only the imagination sets limits for its use.</p>
|
||||
<p>Upgrade wise there can be an impact if data is moved out of tables to be reinserted again because of a change to a database structure. This will cause the Unique Record Identifier to change, unless steps are taken to avoid this, and the links will need to be reestablished.</p>
|
||||
<p>Other risks could be if Transfer Fields are used and data is being copied unintentionally.</p>
|
||||
<h2 id=nav-usages><strong>NAV Usages</strong></h2>
|
||||
<h2 id=nav-usages>NAV Usages</h2>
|
||||
<p>This is a new pattern not currently used in Microsoft Dynamics NAV.</p>
|
||||
<h2 id=ideas-for-improvement><strong>Ideas for improvement</strong></h2>
|
||||
<h2 id=ideas-for-improvement>Ideas for improvement</h2>
|
||||
<p>The reason for doing it this way is that you now can reuse your code again and again with only creating the same link on other tables instead of building it from scratch each time reducing testing needed and improving the quality of the overall product.</p>
|
||||
<h2 id=consequences-when-it-should-not-be-used><strong>Consequences (When it should not be used)</strong></h2>
|
||||
<h2 id=consequences-when-it-should-not-be-used>Consequences (When it should not be used)</h2>
|
||||
<p>This can be used on any table when linking anything to it that can be considered a generic module which can be reused. That said it should not be used in cases where there is a risk of tables growing so much that performance could be impacted. There are ways to reduce performance impact when using high volume tables, but that is outside the scope of this pattern.</p>
|
||||
<h2 id=related-topics><strong>Related Topics</strong></h2>
|
||||
<h2 id=related-topics>Related Topics</h2>
|
||||
<p>This is related to the hook pattern as far as they both try to reduce the footprint changes have on the standard application, by creating reusable ways to interact with the standard code. That said the hook pattern is more about hooking the functionality to existing while this pattern is more about creating reusable ways of creating functionality.</p>
|
||||
<p>__</p>
|
||||
<footer class=footline>
|
||||
</footer>
|
||||
</main>
|
||||
|
|
@ -357,12 +346,12 @@ ALGuidelines.Dev
|
|||
<div style=left:-1000px;overflow:scroll;position:absolute;top:-1000px;border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px>
|
||||
<div style=border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px></div>
|
||||
</div>
|
||||
<script src=/js/clipboard.min.js?1644506468></script>
|
||||
<script src=/js/perfect-scrollbar.min.js?1644506468></script>
|
||||
<script src=/js/perfect-scrollbar.jquery.min.js?1644506468></script>
|
||||
<script src=/js/jquery.svg.pan.zoom.js?1644506468></script>
|
||||
<script src=/js/featherlight.min.js?1644506468></script>
|
||||
<script src=/js/modernizr.custom-3.6.0.js?1644506468></script>
|
||||
<script src=/js/relearn.js?1644506468></script>
|
||||
<script src=/js/clipboard.min.js?1644600599></script>
|
||||
<script src=/js/perfect-scrollbar.min.js?1644600599></script>
|
||||
<script src=/js/perfect-scrollbar.jquery.min.js?1644600599></script>
|
||||
<script src=/js/jquery.svg.pan.zoom.js?1644600599></script>
|
||||
<script src=/js/featherlight.min.js?1644600599></script>
|
||||
<script src=/js/modernizr.custom-3.6.0.js?1644600599></script>
|
||||
<script src=/js/relearn.js?1644600599></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue