alguidelines.dev - Business Central Design Patterns – Best Practiceshttps://alguidelines.dev/docs/bestpractices/Recent content in Best Practices on alguidelines.dev - Business Central Design PatternsHugo -- gohugo.ioen-usDocs: begin as an afterwordhttps://alguidelines.dev/docs/bestpractices/begin-as-an-afterword/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/begin-as-an-afterword/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>When <code>begin</code> follows <code>then</code>, <code>else</code>, <code>do</code>, it should be on the same line, preceded by one space character.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ICPartnerRefType<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>ICPartnerRefType<span style="color:#000;font-weight:bold">::</span>&#34;Common Item No.&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ICPartnerRefType<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>ICPartnerRefType<span style="color:#000;font-weight:bold">::</span>&#34;Common Item No.&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qbeginasanafterwordcategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=begin+as+an+After+Word+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Begin-End - Compound Onlyhttps://alguidelines.dev/docs/bestpractices/begin-end/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/begin-end/ <p><em>Created by Microsoft, Described by waldo</em></p> <p>Only use begin..end to enclose <a href="https://docs.microsoft.com/en-us/cpp/c-language/compound-statement-c?view=msvc-170#:~:text=A%20compound%20statement%20%28also%20called%20a%20%22block%22%29%20typically,appear%20at%20the%20head%20of%20a%20compound%20statement.">compound statements</a>.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>FindSet<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">repeat</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">until</span><span style="color:#f8f8f8;text-decoration:underline"> </span>next<span style="color:#ce5c00;font-weight:bold">() </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>FindSet<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">repeat</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">until</span><span style="color:#f8f8f8;text-decoration:underline"> </span>next<span style="color:#ce5c00;font-weight:bold">() </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="bad-code-1">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsAssemblyOutputLine<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">TestField</span><span style="color:#ce5c00;font-weight:bold">(</span>&#34;Order Line No.&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code-1">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsAssemblyOutputLine<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">TestField</span><span style="color:#ce5c00;font-weight:bold">(</span>&#34;Order Line No.&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="exception">Exception</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#8f5902;font-style:italic">// Except for this case </span><span style="color:#8f5902;font-style:italic"></span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>X<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Y<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">//DO SOMETHING; </span><span style="color:#8f5902;font-style:italic"></span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">not</span><span style="color:#f8f8f8;text-decoration:underline"> </span>X<span style="color:#ce5c00;font-weight:bold">) </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qbeginendcompoundonlycategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=begin+end+compound+only+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Binary Operator to Start Linehttps://alguidelines.dev/docs/bestpractices/binary-operator-line-start/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/binary-operator-line-start/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>Do not start a line with a binary operator.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL">&#34;Quantity to Ship&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>Quantity<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Quantity Shipped&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL">&#34;Quantity to Ship&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>Quantity<span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>&#34;Quantity Shipped&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qbinaryoperatortostartlinecategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=binary+operator+to+start+line+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: CASE Action on next linehttps://alguidelines.dev/docs/bestpractices/case-actions/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/case-actions/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>A CASE action should start on a line after the possibility.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">case</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Letter<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">of</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;A&#39;</span><span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Letter2<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;10&#39;</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;B&#39;</span><span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Letter2<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;11&#39;</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">case</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Letter<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">of</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;A&#39;</span><span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Letter2<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;10&#39;</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;B&#39;</span><span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Letter2<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;11&#39;</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qcaseactiononnextlinecategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=case+action+on+next+line+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Comment Spacinghttps://alguidelines.dev/docs/bestpractices/comments-spacing/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/comments-spacing/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>Always start comments with // followed by one space character.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al">RowNo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">+=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">//Move way below the budget </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al">RowNo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">+=</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">// Move way below the budget </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qcommentspacingcategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=comment+spacing+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: DeleteAllhttps://alguidelines.dev/docs/bestpractices/deleteall/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/deleteall/ <p><em>Created by waldo, Described by waldo</em></p> <h2 id="description">Description</h2> <p>When you perform a &ldquo;DeleteAll&rdquo; when there is nothing to delete, it will still perform a lock. When you for example perform a DeleteAll on an empty table, it will result in a table lock. Therefore it&rsquo;s good practice to always check if the table is empty when performing a DeleteAll.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>EmptyTableWLD<span style="color:#ce5c00;font-weight:bold">.</span>SetRange<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">Code</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;AJ&#39;</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>EmptyTableWLD<span style="color:#ce5c00;font-weight:bold">.</span>DeleteAll<span style="color:#ce5c00;font-weight:bold">(</span>true<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>EmptyTableWLD<span style="color:#ce5c00;font-weight:bold">.</span>SetRange<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">Code</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;AJ&#39;</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">not</span><span style="color:#f8f8f8;text-decoration:underline"> </span>EmptyTableWLD<span style="color:#ce5c00;font-weight:bold">.</span>IsEmpty<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>EmptyTableWLD<span style="color:#ce5c00;font-weight:bold">.</span>DeleteAll<span style="color:#ce5c00;font-weight:bold">(</span>true<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussions">Discussions</h2> <p>You can discuss the guideline <a href="https://github.com/microsoft/alguidelines/discussions/107">here</a></p> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: end else pairhttps://alguidelines.dev/docs/bestpractices/end-else-pair/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/end-else-pair/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>The <code>end else</code> pair should always appear on the same line.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OppEntry<span style="color:#ce5c00;font-weight:bold">.</span>Find<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;-&#39;</span><span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SalesCycleStage<span style="color:#ce5c00;font-weight:bold">.</span>Find<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;-&#39;</span><span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OppEntry<span style="color:#ce5c00;font-weight:bold">.</span>Find<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;-&#39;</span><span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SalesCycleStage<span style="color:#ce5c00;font-weight:bold">.</span>Find<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;-&#39;</span><span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qendelsepaircategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=end+else/pair+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Keyword Pairs - Indentationhttps://alguidelines.dev/docs/bestpractices/keyword-pairs-indentation/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/keyword-pairs-indentation/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>The <code>if..then</code> pair, <code>while..do</code> pair, and <code>for..do</code> pair must appear on the same line or the same level of indentation. If possible, you can align the lines it is even much more readable.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">(</span>x<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>y<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">and</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">(</span>a<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>b<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">(</span>x<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>y<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">and</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">(</span>a<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>b<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qkeywordpairindentationcategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=keyword+pair+indentation+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Line Start Keywordshttps://alguidelines.dev/docs/bestpractices/line-start-keywords/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/line-start-keywords/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>The <code>end</code>, <code>if</code>, <code>repeat</code>, <code>for</code>, <code>while</code>, <code>else</code> and <code>case</code> statement should always start a line.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsContactName<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ValidateContactName<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsSalespersonCode<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ValidateSalespersonCode<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsSalesCycleCode<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ValidatSalesCycleCode<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsContactName<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>ValidateContactName<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsSalespersonCode<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>ValidateSalespersonCode<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsSalesCycleCode<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>ValidatSalesCycleCode<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qlinestartkeywordcategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=line+start+keyword+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Lonely Repeathttps://alguidelines.dev/docs/bestpractices/lonely-repeat/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/lonely-repeat/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>The <code>repeat</code> statement should always be alone on a line.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ReservEntry<span style="color:#ce5c00;font-weight:bold">.</span>FindSet<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">repeat</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ReservEntry<span style="color:#ce5c00;font-weight:bold">.</span>FindSet<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">repeat</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qlonelyrepeatcategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=lonely+repeat+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Named Invocationshttps://alguidelines.dev/docs/bestpractices/named-invocations/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/named-invocations/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>When calling an object statically use the Object Name, not the Object Id.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Page</span><span style="color:#ce5c00;font-weight:bold">.</span>RunModal<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#0000cf;font-weight:bold">525</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SalesShptLine<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Page</span><span style="color:#ce5c00;font-weight:bold">.</span>RunModal<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">Page</span><span style="color:#000;font-weight:bold">::</span>&#34;Posted Sales Shipment Lines&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SalesShptLine<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qnamedinvocationscategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=named+invocations+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: One Statement per Linehttps://alguidelines.dev/docs/bestpractices/one-statement-per-line/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/one-statement-per-line/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>A line of code should not have more than one statement.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OppEntry<span style="color:#ce5c00;font-weight:bold">.</span>Find<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;-&#39;</span><span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">exit</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OppEntry<span style="color:#ce5c00;font-weight:bold">.</span>Find<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;-&#39;</span><span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">exit</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="bad-code-1">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>TotalCost<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">+=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Cost<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>TotalAmt<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">+=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Amt<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code-1">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>TotalCost<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">+=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Cost<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>TotalAmt<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">+=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Amt<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qonestatementperlinecategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=one+statement+per+line+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Seperate if and elsehttps://alguidelines.dev/docs/bestpractices/separate-if-and-else/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/separate-if-and-else/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p><code>if</code> and <code>else</code> statements should be on separate lines.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Atom<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;\&gt;&#39;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span>HasLogicalOperator<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Atom<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;\&gt;&#39;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>HasLogicalOperator<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qseparateifandelsecategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=separate+if+and+else+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Spacing Binary Operatorshttps://alguidelines.dev/docs/bestpractices/spacing-binary-operators/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/spacing-binary-operators/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>There must be exactly one space character on each side of a binary operator such as = + - AND OR =. The parameter comma operator however, should have a space after the comma.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Line Discount %&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Line Discount Amount&#34;/&#34;Line Value&#34;*<span style="color:#0000cf;font-weight:bold">100</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Line Discount %&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Line Discount Amount&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span>/<span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Line Value&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span>*<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">100</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="bad-code-1">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>StartDate<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>CalcDate<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;&lt;+&#39;</span>+Format<span style="color:#ce5c00;font-weight:bold">(</span>Days<span style="color:#ce5c00;font-weight:bold">+</span>i<span style="color:#ce5c00;font-weight:bold">)</span>+<span style="color:#4e9a06">&#39;D\&gt;&#39;</span><span style="color:#000;font-weight:bold">,</span>StartDate<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code-1">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>StartDate<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>CalcDate<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#39;&lt;+&#39;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>+<span style="color:#f8f8f8;text-decoration:underline"> </span>Format<span style="color:#ce5c00;font-weight:bold">(</span>Days<span style="color:#f8f8f8;text-decoration:underline"> </span>+<span style="color:#f8f8f8;text-decoration:underline"> </span>i<span style="color:#ce5c00;font-weight:bold">) </span>+<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;D\&gt;&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>StartDate<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="bad-code-2">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>StartDate<span style="color:#ce5c00;font-weight:bold">:=</span>0D<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">// Initialize </span></code></pre></div><h2 id="good-code-2">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>StartDate<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">:=</span><span style="color:#f8f8f8;text-decoration:underline"> </span>0D<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">// Initialize </span></code></pre></div>Docs: Subscriber Codeunitshttps://alguidelines.dev/docs/bestpractices/subscribercodeunits/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/subscribercodeunits/ <p><em>Created by waldo, Described by waldo</em></p> <h2 id="description">Description</h2> <p>In general, subscribers have to be put in codeunits. There are a few performance considerations that you should keep in the back of your minds, when designing such a codeunit.</p> <ul> <li>Keep the codeunit as small as possible</li> <li>Work with a single instance codeunit</li> <li>only subscribe when necessary</li> <li>Avoid generic OnInsert/OnModify/OnDelete</li> </ul> <p>Let&rsquo;s discuss all points</p> <h2 id="keep-the-codeunit-as-small-as-possible">Keep the codeunit as small as possible</h2> <p>Every time a subscriber gets called, a new instance of the codeunit is being loaded in memory, which takes memory and processing power. The smaller the codeunit, the less memory, and the faster it is.</p> <p>Therefore, it&rsquo;s suggested to split the subscribers by functionality and avoid putting business logic in the actual codeunit. Tip: put all business logic in an &ldquo;<a href="https://alguidelines.dev/bcpatterns/generic-method-pattern/">Method Codeunit</a>&rdquo;.</p> <p>Examples:</p> <ul> <li>if you app does things on Sales and Purchase, create a Sales-subs codeunit, and a Purchase-subs.</li> <li>if you have multiple functionalities in your app (let&rsquo;s call&rsquo;m modules), create a subs-codeunit per module, and only add the subscribers in there that are necessary for that module.</li> </ul> <h3 id="bad-code">Bad code</h3> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">2037325</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Setup Subs&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>{<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>SingleInstance<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>[EventSubscriber<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">ObjectType</span><span style="color:#000;font-weight:bold">::</span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">::</span>&#34;Manual Setup&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnRegisterManualSetup&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#ce5c00;font-weight:bold">)</span>]<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">local</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OnRegisterManualSetup<span style="color:#ce5c00;font-weight:bold">(</span>sender<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup&#34;<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">ModuleInfo</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>NameListLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Linked Texts Framework - List&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionListLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Edit linked texts&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordListLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;LT,Distri,Technical,Functional,Reports&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>NameReportLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Linked Texts Framework - Reports&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionReportLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;View linked texts reports&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordReportLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;LT,Distri,Technical,Functional,Reports&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>navapp<span style="color:#ce5c00;font-weight:bold">.</span>GetCurrentModuleInfo<span style="color:#ce5c00;font-weight:bold">(</span>AppId<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Sender<span style="color:#ce5c00;font-weight:bold">.</span>Insert<span style="color:#ce5c00;font-weight:bold">(</span>NameListLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionListLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordListLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">page</span><span style="color:#000;font-weight:bold">::</span>&#34;LTE Linked Text List&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#ce5c00;font-weight:bold">.</span>Id<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup Category&#34;<span style="color:#000;font-weight:bold">::</span>General<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Sender<span style="color:#ce5c00;font-weight:bold">.</span>Insert<span style="color:#ce5c00;font-weight:bold">(</span>NameReportLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionReportLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordReportLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">page</span><span style="color:#000;font-weight:bold">::</span>&#34;LTE Linked Texts Reports&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#ce5c00;font-weight:bold">.</span>Id<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup Category&#34;<span style="color:#000;font-weight:bold">::</span>General<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>[EventSubscriber<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">ObjectType</span><span style="color:#000;font-weight:bold">::</span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#000;font-weight:bold">::</span>&#34;Manual Setup&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnRegisterManualSetup&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#ce5c00;font-weight:bold">)</span>]<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">local</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OnRegisterManualSetup<span style="color:#ce5c00;font-weight:bold">(</span>sender<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup&#34;<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">ModuleInfo</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>NameLayoutLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Report Helper - Layout&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionLayoutLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Set up or update report layout list&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordLayoutLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;RH,Distri,Technical,Functional,Reports,Layout&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>NameCaptionsLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Report Helper - Captions&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionCaptionsLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Set up or update captions list&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordCaptionsLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;RH,Distri,Technical,Functional,Reports,Captions&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>NameFunctionsLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Report Helper - Functions&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionFunctionsLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Set up or disable functions&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordFunctionsLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;RH,Distri,Technical,Functional,Reports,Functions&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>NameDFCLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Report Helper - Default Footer&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionDFCLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Set up or update default footer&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordDFCLbl<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Label</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;RH,Distri,Technical,Functional,Reports,Default,Footer&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Locked<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>navapp<span style="color:#ce5c00;font-weight:bold">.</span>GetCurrentModuleInfo<span style="color:#ce5c00;font-weight:bold">(</span>AppId<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Sender<span style="color:#ce5c00;font-weight:bold">.</span>Insert<span style="color:#ce5c00;font-weight:bold">(</span>NameLayoutLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionLayoutLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordLayoutLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">page</span><span style="color:#000;font-weight:bold">::</span>&#34;RHE Report Layout List&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#ce5c00;font-weight:bold">.</span>Id<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup Category&#34;<span style="color:#000;font-weight:bold">::</span>General<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Sender<span style="color:#ce5c00;font-weight:bold">.</span>Insert<span style="color:#ce5c00;font-weight:bold">(</span>NameCaptionsLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionCaptionsLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordCaptionsLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">page</span><span style="color:#000;font-weight:bold">::</span>&#34;RHE Captions&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#ce5c00;font-weight:bold">.</span>Id<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup Category&#34;<span style="color:#000;font-weight:bold">::</span>General<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Sender<span style="color:#ce5c00;font-weight:bold">.</span>Insert<span style="color:#ce5c00;font-weight:bold">(</span>NameFunctionsLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionFunctionsLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordFunctionsLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">page</span><span style="color:#000;font-weight:bold">::</span>&#34;RHE Functions&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#ce5c00;font-weight:bold">.</span>Id<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup Category&#34;<span style="color:#000;font-weight:bold">::</span>General<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Sender<span style="color:#ce5c00;font-weight:bold">.</span>Insert<span style="color:#ce5c00;font-weight:bold">(</span>NameDFCLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DescriptionDFCLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KeyWordDFCLbl<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">page</span><span style="color:#000;font-weight:bold">::</span>&#34;RHE Default Footer Card&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AppId<span style="color:#ce5c00;font-weight:bold">.</span>Id<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup Category&#34;<span style="color:#000;font-weight:bold">::</span>General<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>}<span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h3 id="good-code">Good code</h3> <p>Split into 2 codeunits, and move the business logic out.</p> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">2037325</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;LTE Setup Subs&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>{<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>SingleInstance<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>[EventSubscriber<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">ObjectType</span><span style="color:#000;font-weight:bold">::</span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">::</span>&#34;Manual Setup&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnRegisterManualSetup&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#ce5c00;font-weight:bold">)</span>]<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">local</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OnRegisterManualSetup<span style="color:#ce5c00;font-weight:bold">(</span>sender<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup&#34;<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterLTEManualSetup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Register LTE Manual Setup&#34;<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterLTEManualSetup<span style="color:#ce5c00;font-weight:bold">.</span>RegisterLTEManualSetup<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>}<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">2037324</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;RHE Setup Subs&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>{<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>SingleInstance<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>[EventSubscriber<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">ObjectType</span><span style="color:#000;font-weight:bold">::</span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">::</span>&#34;Manual Setup&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnRegisterManualSetup&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#ce5c00;font-weight:bold">)</span>]<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">local</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OnRegisterManualSetup<span style="color:#ce5c00;font-weight:bold">(</span>sender<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup&#34;<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterRHEManualSetup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Register RHE Manual Setup&#34;<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterRHEManualSetup<span style="color:#ce5c00;font-weight:bold">.</span>RegisterRHEManualSetup<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>}<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="work-with-a-single-instance-codeunit">Work with a single instance codeunit</h2> <p>To avoid the extra &ldquo;loading of the content&rdquo; while a subscriber is being executed, use Single Instance codeunit for subscribers. Do take into account, of course, that it would share the state across the entire session.</p> <h3 id="bad-code-1">Bad code</h3> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">2037324</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;RHE Setup Subs&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>{<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>[EventSubscriber<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">ObjectType</span><span style="color:#000;font-weight:bold">::</span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">::</span>&#34;Manual Setup&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnRegisterManualSetup&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#ce5c00;font-weight:bold">)</span>]<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">local</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OnRegisterManualSetup<span style="color:#ce5c00;font-weight:bold">(</span>sender<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup&#34;<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterRHEManualSetup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Register RHE Manual Setup&#34;<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterRHEManualSetup<span style="color:#ce5c00;font-weight:bold">.</span>RegisterRHEManualSetup<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>}<span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h3 id="good-code-1">Good code</h3> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">2037324</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;RHE Setup Subs&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>{<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>SingleInstance<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>[EventSubscriber<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">ObjectType</span><span style="color:#000;font-weight:bold">::</span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#000;font-weight:bold">::</span>&#34;Manual Setup&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnRegisterManualSetup&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#ce5c00;font-weight:bold">)</span>]<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">local</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>OnRegisterManualSetup<span style="color:#ce5c00;font-weight:bold">(</span>sender<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Manual Setup&#34;<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterRHEManualSetup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Register RHE Manual Setup&#34;<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>RegisterRHEManualSetup<span style="color:#ce5c00;font-weight:bold">.</span>RegisterRHEManualSetup<span style="color:#ce5c00;font-weight:bold">()</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"></span>}<span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="only-subscribe-when-necessary">only subscribe when necessary</h2> <p>If possible, only execute the subscriber when really necessary by using Manual Binding.</p> <h3 id="bad-code-2">Bad code</h3> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">//subscriber - code should actually only run when Color=Red. </span><span style="color:#8f5902;font-style:italic"></span><span style="color:#f8f8f8;text-decoration:underline"> </span>[EventSubscriber<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">ObjectType</span><span style="color:#000;font-weight:bold">::</span><span style="color:#204a87;font-weight:bold">Table</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Database</span><span style="color:#000;font-weight:bold">::</span>&#34;Just Some Table WLD&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnAfterValidateEvent&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;Message 2&#39;</span><span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>false<span style="color:#ce5c00;font-weight:bold">)</span>]<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">local</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustDoSomthing<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Rec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Record</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Just Some Table WLD&#34;<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">var</span><span style="color:#f8f8f8;text-decoration:underline"> </span>xRec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Record</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Just Some Table WLD&#34;<span style="color:#ce5c00;font-weight:bold">) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Rec<span style="color:#ce5c00;font-weight:bold">.</span>color<span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;&gt;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;RED&#39;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">exit</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">//only execute when necessary </span><span style="color:#8f5902;font-style:italic"></span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">... </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">//business logic </span><span style="color:#8f5902;font-style:italic"></span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>FindSet<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">repeat</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>Validate<span style="color:#ce5c00;font-weight:bold">(</span>&#34;Message 2&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>format<span style="color:#ce5c00;font-weight:bold">(</span>Random<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#ce5c00;font-weight:bold">)))</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">until</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>Next<span style="color:#ce5c00;font-weight:bold">() </span>&lt;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h3 id="good-code-2">Good code</h3> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-AL" data-lang="AL"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>FindSet<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">repeat</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>Color<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;RED&#39;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>BindSubscription<span style="color:#ce5c00;font-weight:bold">(</span>DemoSubs<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>Validate<span style="color:#ce5c00;font-weight:bold">(</span>&#34;Message 2&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span>format<span style="color:#ce5c00;font-weight:bold">(</span>Random<span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#ce5c00;font-weight:bold">)))</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>Color<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;RED&#39;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>UnbindSubscription<span style="color:#ce5c00;font-weight:bold">(</span>DemoSubs<span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">until</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JustSomeTable<span style="color:#ce5c00;font-weight:bold">.</span>Next<span style="color:#ce5c00;font-weight:bold">() </span>&lt;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="avoid-oninsertonmodifyondelete">Avoid OnInsert/OnModify/OnDelete</h2> <p>The reason for this is, that it breaks the batch-calls:</p> <ul> <li>Any &ldquo;OnInsert&rdquo; subscriber breaks the bulk inserts, simply because it needs to perform an operation after every record that was inserted</li> <li>Any &ldquo;OnModify&rdquo; subscriber slows down the &ldquo;ModifyAll&rdquo;, simply because it needs to perform an operation after every record that was modified. I fact: 1 SQL call is turned into a loop of SQL calls.</li> <li>Any &ldquo;OnDelete&rdquo; subscriber slows down the &ldquo;DeleteAll&rdquo;, simply because it needs to perform an operation after every record that was deleted. I fact: 1 SQL call is turned into a loop of SQL calls.</li> </ul> <p>Avoid subscribers to these events.</p> <h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussions92"><a href="https://github.com/microsoft/alguidelines/discussions/92">Discussions</a></h2> <p>You can discuss this guidelines <a href="https://github.com/microsoft/alguidelines/discussions/92">here</a>.</p> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p> <h2 id="references">References</h2> <p>The <a href="https://alguidelines.dev/bcpatterns/generic-method-pattern/">Generic Method Pattern</a></p>Docs: Suggested Abbreviationshttps://alguidelines.dev/docs/bestpractices/suggested-abbreviations/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/suggested-abbreviations/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>Whenever possible, do <strong>not</strong> use abbreviations in variables, functions and objects names.</p> <p>If there is no other choice, then use the suggestions below.</p> <table> <thead> <tr> <th>word</th> <th>Abbreviation</th> </tr> </thead> <tbody> <tr> <td>absence</td> <td>Abs</td> </tr> <tr> <td>account</td> <td>Acc</td> </tr> <tr> <td>accounting</td> <td>Acc</td> </tr> <tr> <td>accumulated</td> <td>Accum</td> </tr> <tr> <td>action</td> <td>Act</td> </tr> <tr> <td>activity</td> <td>Activ</td> </tr> <tr> <td>additional</td> <td>Add</td> </tr> <tr> <td>address</td> <td>Addr</td> </tr> <tr> <td>adjust</td> <td>Adj</td> </tr> <tr> <td>adjusted</td> <td>Adjd</td> </tr> <tr> <td>adjustment</td> <td>Adjmt</td> </tr> <tr> <td>agreement</td> <td>Agrmt</td> </tr> <tr> <td>allocation</td> <td>Alloc</td> </tr> <tr> <td>allowance</td> <td>Allow</td> </tr> <tr> <td>alternative</td> <td>Alt</td> </tr> <tr> <td>amount</td> <td>Amt</td> </tr> <tr> <td>amounts</td> <td>Amts</td> </tr> <tr> <td>answer</td> <td>Ans</td> </tr> <tr> <td>applies</td> <td>Appl</td> </tr> <tr> <td>application</td> <td>Appln</td> </tr> <tr> <td>arrival</td> <td>Arriv</td> </tr> <tr> <td>assembly</td> <td>Asm</td> </tr> <tr> <td>assemble to order</td> <td>ATO</td> </tr> <tr> <td>assignment</td> <td>Assgnt</td> </tr> <tr> <td>associated</td> <td>Assoc</td> </tr> <tr> <td>attachment</td> <td>Attmt</td> </tr> <tr> <td>authorities</td> <td>Auth</td> </tr> <tr> <td>automatic</td> <td>Auto</td> </tr> <tr> <td>availability</td> <td>Avail</td> </tr> <tr> <td>average</td> <td>Avg</td> </tr> <tr> <td>ba db.</td> <td>BA</td> </tr> <tr> <td>balance</td> <td>Bal</td> </tr> <tr> <td>bill of materials</td> <td>BOM</td> </tr> <tr> <td>blanket</td> <td>Blnkt</td> </tr> <tr> <td>budget</td> <td>Budg</td> </tr> <tr> <td>buffer</td> <td>Buf</td> </tr> <tr> <td>business</td> <td>Bus</td> </tr> <tr> <td>business interaction management</td> <td>BIM</td> </tr> <tr> <td>buying</td> <td>Buy</td> </tr> <tr> <td>calculate</td> <td>Calc</td> </tr> <tr> <td>calculated</td> <td>Calcd</td> </tr> <tr> <td>calculation</td> <td>Calcu</td> </tr> <tr> <td>calendar</td> <td>Cal</td> </tr> <tr> <td>capacity</td> <td>Cap</td> </tr> <tr> <td>capacity requirements planning</td> <td>CRP</td> </tr> <tr> <td>cash flow</td> <td>CF</td> </tr> <tr> <td>cashflow</td> <td>CF</td> </tr> <tr> <td>catalog</td> <td>ctlg</td> </tr> <tr> <td>category</td> <td>Cat</td> </tr> <tr> <td>Central Processing Unit</td> <td>CPU</td> </tr> <tr> <td>center</td> <td>Ctr</td> </tr> <tr> <td>change</td> <td>Chg</td> </tr> <tr> <td>changes</td> <td>Chgs</td> </tr> <tr> <td>character</td> <td>Char</td> </tr> <tr> <td>characters</td> <td>Chars</td> </tr> <tr> <td>charge</td> <td>Chrg</td> </tr> <tr> <td>charges</td> <td>Chrgs</td> </tr> <tr> <td>check</td> <td>Chk</td> </tr> <tr> <td>classification</td> <td>Class</td> </tr> <tr> <td>collection</td> <td>coll</td> </tr> <tr> <td>column</td> <td>col</td> </tr> <tr> <td>comment</td> <td>Cmt</td> </tr> <tr> <td>company</td> <td>Co</td> </tr> <tr> <td>component</td> <td>Comp</td> </tr> <tr> <td>completion</td> <td>Cmpltn</td> </tr> <tr> <td>components</td> <td>Comps</td> </tr> <tr> <td>composition</td> <td>Compn</td> </tr> <tr> <td>compression</td> <td>Compr</td> </tr> <tr> <td>concurrent</td> <td>Concrnt</td> </tr> <tr> <td>confidential</td> <td>Conf</td> </tr> <tr> <td>confirmation</td> <td>Cnfrmn</td> </tr> <tr> <td>conflict</td> <td>Confl</td> </tr> <tr> <td>consolidate</td> <td>Consol</td> </tr> <tr> <td>consolidation</td> <td>Consolid</td> </tr> <tr> <td>consumption</td> <td>Consump</td> </tr> <tr> <td>contact</td> <td>Cont</td> </tr> <tr> <td>container</td> <td>Cntr</td> </tr> <tr> <td>contract</td> <td>Contr</td> </tr> <tr> <td>contracted</td> <td>Contrd</td> </tr> <tr> <td>control</td> <td>Ctrl</td> </tr> <tr> <td>controls</td> <td>Ctrls</td> </tr> <tr> <td>conversion</td> <td>Conv</td> </tr> <tr> <td>correction</td> <td>Cor</td> </tr> <tr> <td>correspondence</td> <td>Corres</td> </tr> <tr> <td>corresponding</td> <td>Corresp</td> </tr> <tr> <td>cost</td> <td>Cst</td> </tr> <tr> <td>sold</td> <td>COGS</td> </tr> <tr> <td>credit</td> <td>Cr</td> </tr> <tr> <td>cumulate</td> <td>Cumul</td> </tr> <tr> <td>currency</td> <td>Curr</td> </tr> <tr> <td>current</td> <td>Crnt</td> </tr> <tr> <td>customer</td> <td>Cust</td> </tr> <tr> <td>customer/vendor</td> <td>CV</td> </tr> <tr> <td>daily</td> <td>Dly</td> </tr> <tr> <td>dampener</td> <td>Damp</td> </tr> <tr> <td>database management system</td> <td>DBMS</td> </tr> <tr> <td>date</td> <td>D</td> </tr> <tr> <td>definition</td> <td>Def</td> </tr> <tr> <td>demonstration</td> <td>Demo</td> </tr> <tr> <td>department</td> <td>Dept</td> </tr> <tr> <td>department/project</td> <td>DP</td> </tr> <tr> <td>depreciation</td> <td>Depr</td> </tr> <tr> <td>description</td> <td>Desc</td> </tr> <tr> <td>detail</td> <td>Dtl</td> </tr> <tr> <td>detailed</td> <td>Dtld</td> </tr> <tr> <td>details</td> <td>Dtls</td> </tr> <tr> <td>deviation</td> <td>Dev</td> </tr> <tr> <td>difference</td> <td>Diff</td> </tr> <tr> <td>dimension</td> <td>Dim</td> </tr> <tr> <td>direct</td> <td>Dir</td> </tr> <tr> <td>discount</td> <td>Disc</td> </tr> <tr> <td>discrete</td> <td>Discr</td> </tr> <tr> <td>distribute</td> <td>Distr</td> </tr> <tr> <td>distributed</td> <td>Distrd</td> </tr> <tr> <td>distributor</td> <td>Distbtr</td> </tr> <tr> <td>distribution</td> <td>Distrn</td> </tr> <tr> <td>document</td> <td>Doc</td> </tr> <tr> <td>duplicate</td> <td>Dupl</td> </tr> <tr> <td>entered</td> <td>Entrd</td> </tr> <tr> <td>engineering</td> <td>Engin</td> </tr> <tr> <td>exchange</td> <td>Exch</td> </tr> <tr> <td>excluding</td> <td>Excl</td> </tr> <tr> <td>execute</td> <td>Exec</td> </tr> <tr> <td>expected</td> <td>Expd</td> </tr> <tr> <td>expedited</td> <td>Exped</td> </tr> <tr> <td>expense</td> <td>Exp</td> </tr> <tr> <td>expression</td> <td>Expr</td> </tr> <tr> <td>expiration</td> <td>Expir</td> </tr> <tr> <td>extended</td> <td>Ext</td> </tr> <tr> <td>explode</td> <td>Expl</td> </tr> <tr> <td>export</td> <td>Expt</td> </tr> <tr> <td>final</td> <td>Fnl</td> </tr> <tr> <td>finance</td> <td>Fin</td> </tr> <tr> <td>fiscal</td> <td>Fisc</td> </tr> <tr> <td>finished</td> <td>Fnshd</td> </tr> <tr> <td>fixed asset</td> <td>FA</td> </tr> <tr> <td>forward</td> <td>Fwd</td> </tr> <tr> <td>freight</td> <td>Frt</td> </tr> <tr> <td>general</td> <td>Gen</td> </tr> <tr> <td>general ledger</td> <td>GL</td> </tr> <tr> <td>group</td> <td>Gr</td> </tr> <tr> <td>header</td> <td>Hdr</td> </tr> <tr> <td>history</td> <td>Hist</td> </tr> <tr> <td>holiday</td> <td>Hol</td> </tr> <tr> <td>human resource</td> <td>HR</td> </tr> <tr> <td>identification</td> <td>ID</td> </tr> <tr> <td>import</td> <td>Imp</td> </tr> <tr> <td>inbound</td> <td>Inbnd</td> </tr> <tr> <td>including</td> <td>Incl</td> </tr> <tr> <td>included</td> <td>Incld</td> </tr> <tr> <td>incoming</td> <td>Incmg</td> </tr> <tr> <td>independent software vendor</td> <td>ISV</td> </tr> <tr> <td>industry</td> <td>Indust</td> </tr> <tr> <td>information</td> <td>Info</td> </tr> <tr> <td>initial</td> <td>Init</td> </tr> <tr> <td>Intrastat</td> <td>Intra</td> </tr> <tr> <td>interaction</td> <td>Interact</td> </tr> <tr> <td>integration</td> <td>Integr</td> </tr> <tr> <td>interest</td> <td>Int</td> </tr> <tr> <td>Interim</td> <td>Intm</td> </tr> <tr> <td>internal protocol</td> <td>IP</td> </tr> <tr> <td>inventory</td> <td>Invt</td> </tr> <tr> <td>inventoriable</td> <td>Invtbl</td> </tr> <tr> <td>invoice</td> <td>Inv</td> </tr> <tr> <td>invoiced</td> <td>Invd</td> </tr> <tr> <td>item tracking</td> <td>IT</td> </tr> <tr> <td>journal</td> <td>Jnl</td> </tr> <tr> <td>language</td> <td>Lang</td> </tr> <tr> <td>ledger</td> <td>Ledg</td> </tr> <tr> <td>level</td> <td>Lvl</td> </tr> <tr> <td>line</td> <td>Ln</td> </tr> <tr> <td>list</td> <td>Lt</td> </tr> <tr> <td>local currency</td> <td>LCY</td> </tr> <tr> <td>location</td> <td>Loc</td> </tr> <tr> <td>mailing</td> <td>Mail</td> </tr> <tr> <td>maintenance</td> <td>Maint</td> </tr> <tr> <td>management</td> <td>Mgt</td> </tr> <tr> <td>manual</td> <td>Man</td> </tr> <tr> <td>manufacturing</td> <td>Mfg</td> </tr> <tr> <td>manufacturer</td> <td>Mfr</td> </tr> <tr> <td>material</td> <td>Mat</td> </tr> <tr> <td>marketing</td> <td>Mktg</td> </tr> <tr> <td>maximum</td> <td>Max</td> </tr> <tr> <td>measure</td> <td>Meas</td> </tr> <tr> <td>message</td> <td>Msg</td> </tr> <tr> <td>minimum</td> <td>Min</td> </tr> <tr> <td>miscellaneous</td> <td>Misc</td> </tr> <tr> <td>modify</td> <td>Mod</td> </tr> <tr> <td>month</td> <td>Mth</td> </tr> <tr> <td>negative</td> <td>Neg</td> </tr> <tr> <td>non-inventoriable</td> <td>NonInvtbl</td> </tr> <tr> <td>notification</td> <td>Notif</td> </tr> <tr> <td>number</td> <td>No</td> </tr> <tr> <td>numbers</td> <td>Nos</td> </tr> <tr> <td>object</td> <td>Obj</td> </tr> <tr> <td>operating</td> <td>Oper</td> </tr> <tr> <td>opportunity</td> <td>Opp</td> </tr> <tr> <td>order</td> <td>Ord</td> </tr> <tr> <td>orders</td> <td>Ords</td> </tr> <tr> <td>original</td> <td>Orig</td> </tr> <tr> <td>organization</td> <td>Org</td> </tr> <tr> <td>outbound</td> <td>Outbnd</td> </tr> <tr> <td>Outgoing</td> <td>Outg</td> </tr> <tr> <td>output</td> <td>Out</td> </tr> <tr> <td>outstanding</td> <td>Outstd</td> </tr> <tr> <td>overhead</td> <td>Ovhd</td> </tr> <tr> <td>payment</td> <td>Pmt</td> </tr> <tr> <td>percent</td> <td>Pct</td> </tr> <tr> <td>personnel</td> <td>Persnl</td> </tr> <tr> <td>physical</td> <td>Phys</td> </tr> <tr> <td>picture</td> <td>Pic</td> </tr> <tr> <td>planning</td> <td>Plng</td> </tr> <tr> <td>posted</td> <td>Pstd</td> </tr> <tr> <td>posting</td> <td>Post</td> </tr> <tr> <td>positive</td> <td>Pos</td> </tr> <tr> <td>precision</td> <td>Prec</td> </tr> <tr> <td>prepayment</td> <td>Prepmt</td> </tr> <tr> <td>product</td> <td>Prod</td> </tr> <tr> <td>production</td> <td>Prod</td> </tr> <tr> <td>production order</td> <td>ProdOrd</td> </tr> <tr> <td>project</td> <td>Proj</td> </tr> <tr> <td>property</td> <td>Prop</td> </tr> <tr> <td>prospect</td> <td>Prspct</td> </tr> <tr> <td>purchase</td> <td>Purch</td> </tr> <tr> <td>purchases</td> <td>Purch</td> </tr> <tr> <td>purchaser</td> <td>Purchr</td> </tr> <tr> <td>purchase order</td> <td>PurchOrd</td> </tr> <tr> <td>quality</td> <td>Qlty</td> </tr> <tr> <td>quantity</td> <td>Qty</td> </tr> <tr> <td>questionnaire</td> <td>Questn</td> </tr> <tr> <td>quote</td> <td>Qte</td> </tr> <tr> <td>radio frequency</td> <td>RF</td> </tr> <tr> <td>range</td> <td>Rng</td> </tr> <tr> <td>receipt</td> <td>Rcpt</td> </tr> <tr> <td>received</td> <td>Rcd</td> </tr> <tr> <td>record</td> <td>Rec</td> </tr> <tr> <td>records</td> <td>Recs</td> </tr> <tr> <td>reconcile</td> <td>Recncl</td> </tr> <tr> <td>reconciliation</td> <td>Recon</td> </tr> <tr> <td>recurring</td> <td>Recur</td> </tr> <tr> <td>reference</td> <td>Ref</td> </tr> <tr> <td>register</td> <td>Reg</td> </tr> <tr> <td>registration</td> <td>Regn</td> </tr> <tr> <td>registered</td> <td>Regd</td> </tr> <tr> <td>relation</td> <td>Rel</td> </tr> <tr> <td>relations</td> <td>Rels</td> </tr> <tr> <td>relationship</td> <td>Rlshp</td> </tr> <tr> <td>release</td> <td>Rlse</td> </tr> <tr> <td>released</td> <td>Rlsd</td> </tr> <tr> <td>remaining</td> <td>Rem</td> </tr> <tr> <td>reminder</td> <td>Rmdr</td> </tr> <tr> <td>replacement</td> <td>Repl</td> </tr> <tr> <td>replenish</td> <td>Rplnsh</td> </tr> <tr> <td>replenishment</td> <td>Rplnsht</td> </tr> <tr> <td>report</td> <td>Rpt</td> </tr> <tr> <td>represent</td> <td>Rep</td> </tr> <tr> <td>represented</td> <td>Repd</td> </tr> <tr> <td>request</td> <td>Rqst</td> </tr> <tr> <td>required</td> <td>Reqd</td> </tr> <tr> <td>requirement</td> <td>Reqt</td> </tr> <tr> <td>requirements</td> <td>Reqts</td> </tr> <tr> <td>requisition</td> <td>Req</td> </tr> <tr> <td>reserve</td> <td>Rsv</td> </tr> <tr> <td>reserved</td> <td>Rsvd</td> </tr> <tr> <td>reservation</td> <td>Reserv</td> </tr> <tr> <td>resolution</td> <td>Resol</td> </tr> <tr> <td>resource</td> <td>Res</td> </tr> <tr> <td>response</td> <td>Rsp</td> </tr> <tr> <td>responsibility</td> <td>Resp</td> </tr> <tr> <td>retain</td> <td>Rtn</td> </tr> <tr> <td>retained</td> <td>Rtnd</td> </tr> <tr> <td>return</td> <td>Ret</td> </tr> <tr> <td>returns</td> <td>Rets</td> </tr> <tr> <td>revaluation</td> <td>Revaln</td> </tr> <tr> <td>reverse</td> <td>Rev</td> </tr> <tr> <td>review</td> <td>Rvw</td> </tr> <tr> <td>round</td> <td>Rnd</td> </tr> <tr> <td>rounded</td> <td>Rndd</td> </tr> <tr> <td>rounding</td> <td>Rndg</td> </tr> <tr> <td>route</td> <td>Rte</td> </tr> <tr> <td>routing</td> <td>Rtng</td> </tr> <tr> <td>routine</td> <td>Rout</td> </tr> <tr> <td>sales &amp; receivables</td> <td>Sales</td> </tr> <tr> <td>safety</td> <td>Saf</td> </tr> <tr> <td>schedule</td> <td>Sched</td> </tr> <tr> <td>second</td> <td>Sec</td> </tr> <tr> <td>segment</td> <td>Seg</td> </tr> <tr> <td>select</td> <td>Sel</td> </tr> <tr> <td>selection</td> <td>Selctn</td> </tr> <tr> <td>sequence</td> <td>Seq</td> </tr> <tr> <td>serial</td> <td>Ser</td> </tr> <tr> <td>serial number</td> <td>SN</td> </tr> <tr> <td>service</td> <td>Serv</td> </tr> <tr> <td>sheet</td> <td>Sh</td> </tr> <tr> <td>shipment</td> <td>Shpt</td> </tr> <tr> <td>source</td> <td>Src</td> </tr> <tr> <td>special</td> <td>Spcl</td> </tr> <tr> <td>specification</td> <td>Spec</td> </tr> <tr> <td>specifications</td> <td>Specs</td> </tr> <tr> <td>standard</td> <td>Std</td> </tr> <tr> <td>frequency</td> <td>SF</td> </tr> <tr> <td>statement</td> <td>Stmt</td> </tr> <tr> <td>statistical</td> <td>Stat</td> </tr> <tr> <td>statistics</td> <td>Stats</td> </tr> <tr> <td>stock</td> <td>Stk</td> </tr> <tr> <td>stockkeeping unit</td> <td>SKU</td> </tr> <tr> <td>stream</td> <td>Stm</td> </tr> <tr> <td>structured query language</td> <td>SQL</td> </tr> <tr> <td>subcontract</td> <td>Subcontr</td> </tr> <tr> <td>subcontracted</td> <td>Subcontrd</td> </tr> <tr> <td>subcontracting</td> <td>Subcontrg</td> </tr> <tr> <td>substitute</td> <td>Sub</td> </tr> <tr> <td>substitution</td> <td>Subst</td> </tr> <tr> <td>suggest</td> <td>Sug</td> </tr> <tr> <td>suggested</td> <td>Sugd</td> </tr> <tr> <td>suggestion</td> <td>Sugn</td> </tr> <tr> <td>summary</td> <td>Sum</td> </tr> <tr> <td>suspended</td> <td>Suspd</td> </tr> <tr> <td>symptom</td> <td>Sympt</td> </tr> <tr> <td>synchronize</td> <td>Synch</td> </tr> <tr> <td>temporary</td> <td>Temp</td> </tr> <tr> <td>total</td> <td>Tot</td> </tr> <tr> <td>transaction</td> <td>Transac</td> </tr> <tr> <td>transfer</td> <td>Trans</td> </tr> <tr> <td>translation</td> <td>Transln</td> </tr> <tr> <td>tracking</td> <td>Trkg</td> </tr> <tr> <td>troubleshoot</td> <td>Tblsht</td> </tr> <tr> <td>troubleshooting</td> <td>Tblshtg</td> </tr> <tr> <td>unit of measure</td> <td>UOM</td> </tr> <tr> <td>unit test</td> <td>UT</td> </tr> <tr> <td>unrealized</td> <td>Unreal</td> </tr> <tr> <td>unreserved</td> <td>Unrsvd</td> </tr> <tr> <td>update</td> <td>Upd</td> </tr> <tr> <td>valuation</td> <td>Valn</td> </tr> <tr> <td>value</td> <td>Val</td> </tr> <tr> <td>value added tax</td> <td>VAT</td> </tr> <tr> <td>variance</td> <td>Var</td> </tr> <tr> <td>vendor</td> <td>Vend</td> </tr> <tr> <td>warehouse</td> <td>Whse</td> </tr> <tr> <td>web shop</td> <td>WS</td> </tr> <tr> <td>worksheet</td> <td>Wksh</td> </tr> <tr> <td>g/l</td> <td>GL</td> </tr> <tr> <td>%</td> <td>Pct</td> </tr> <tr> <td>3-tier</td> <td>Three-Tier</td> </tr> <tr> <td>Outlook Synch</td> <td>Osynch</td> </tr> </tbody> </table> <h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qabbreviationscategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=abbreviations+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Unnecessary elsehttps://alguidelines.dev/docs/bestpractices/unnecessary-else/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/unnecessary-else/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p><code>else</code> should not be used when the last action in the <code>then</code> part is an <code>exit</code>, <code>break</code>, <code>skip</code>, <code>quit</code>, <code>error</code>.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SomeProcedure<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsAdjmtBinCodeChanged<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Error<span style="color:#ce5c00;font-weight:bold">(</span>AdjmtBinCodeChangeNotAllowedErr<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">...) </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">else</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Error<span style="color:#ce5c00;font-weight:bold">(</span>BinCodeChangeNotAllowedErr<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">...)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">procedure</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SomeProcedure<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#ce5c00;font-weight:bold"> </span><span style="color:#204a87;font-weight:bold">begin</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsAdjmtBinCodeChanged<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Error<span style="color:#ce5c00;font-weight:bold">(</span>AdjmtBinCodeChangeNotAllowedErr<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">...) </span><span style="color:#ce5c00;font-weight:bold"> </span>Error<span style="color:#ce5c00;font-weight:bold">(</span>BinCodeChangeNotAllowedErr<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">...)</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">end</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qunnecessaryelsecategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=unnecessary+else+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Unnecessary true/falsehttps://alguidelines.dev/docs/bestpractices/unnecessary-truefalse/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/unnecessary-truefalse/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>Do not use <code>true</code> or <code>false</code> keywords unnecessarily if the expression is already an logical expression.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsPositive<span style="color:#ce5c00;font-weight:bold">() </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IsPositive<span style="color:#ce5c00;font-weight:bold">() </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="bad-code-1">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Complete<span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;&gt;<span style="color:#f8f8f8;text-decoration:underline"> </span>true<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code-1">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">if</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">not</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Complete<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">then</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qunnecessarytruefalsecategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=unnecessary+true+false+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Variable Naminghttps://alguidelines.dev/docs/bestpractices/variable-naming/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/variable-naming/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>Variables that refer to a AL object must contain the objects name, abbreviated where necessary.</p> <p>A variable must begin with a capital letter.</p> <p>Blanks, periods, and other characters (such as parentheses) that would make quotation marks around a variable necessary must be omitted.</p> <p>If a variable is a compound of two or more words or abbreviations, each word or abbreviation should begin with a capital letter.</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>WIPBuffer<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Record</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Job WIP Buffer&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>JobWIPBuffer<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Record</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Job WIP Buffer&#34;<span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="bad-code-1">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>Postline<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Gen. Jnl.-Post Line&#34;<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code-1">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>GenJnlPostLine<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Codeunit</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Gen. Jnl.-Post Line&#34;<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="bad-code-2">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>&#34;Amount (LCY)&#34;<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Decimal</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code-2">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>AmountLCY<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Decimal</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qonevariablenamingcategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=one+variable+naming+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>Docs: Variables Declarations Orderhttps://alguidelines.dev/docs/bestpractices/variables-declarations-order/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/docs/bestpractices/variables-declarations-order/ <p><em>Created by Microsoft, Described by waldo</em></p> <h2 id="description">Description</h2> <p>Variables declarations should be ordered by type. In general, object and complex variable types are listed first followed by simple variables. The order should be:</p> <ul> <li>Record</li> <li>Report</li> <li>Codeunit</li> <li>XmlPort</li> <li>Page</li> <li>Query</li> <li>Notification</li> <li>BigText</li> <li>DateFormula</li> <li>RecordId</li> <li>RecordRef</li> <li>FieldRef</li> <li>FilterPageBuilder</li> </ul> <p>(Ref: <a href="https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0021">Microsoft Docs</a>)</p> <h2 id="bad-code">Bad code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>StartingDateFilter<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Text</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>Vendor<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Record</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Vendor<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="good-code">Good code</h2> <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-al" data-lang="al"><span style="color:#f8f8f8;text-decoration:underline"> </span>Vendor<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Record</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Vendor<span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>StartingDateFilter<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">Text</span><span style="color:#000;font-weight:bold">;</span><span style="color:#f8f8f8;text-decoration:underline"> </span></code></pre></div><h2 id="discussionshttpsgithubcommicrosoftalguidelinesdiscussionscategoriesbc-best-practicesdiscussions_qonevariablesdeclarationsordercategory3a22bcbestpractices22"><a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=one+variables+declarations+order+category%3A%22BC+Best+Practices%22">Discussions</a></h2> <p>You can find discussions on all &ldquo;Best Practices&rdquo; <a href="https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices">here</a>.</p> <p>If you don&rsquo;t find the discussion of this guideline, please feel free to create a new one with the same title as this article.</p>