deploy: 8f52709dc8
This commit is contained in:
parent
76c6fda05c
commit
f65c30129b
205 changed files with 668 additions and 566 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -308,6 +308,37 @@ Therefore it’s good practice to always check if the table is empty whe
|
|||
</span></span></span><span style="display:flex;"><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></span><span style="display:flex;"><span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#ce5c00;font-weight:bold">...
|
||||
</span></span></span><span style="display:flex;"><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></span></code></pre></div></description></item><item><title>Docs: IsTemporary record safeguard</title><link>https://alguidelines.dev/docs/bestpractices/istemporary-table-safeguard/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://alguidelines.dev/docs/bestpractices/istemporary-table-safeguard/</guid><description>
|
||||
<p><em>Created by Kine, Described by Kine</em></p>
|
||||
<h2 id="description">Description</h2>
|
||||
<p>When you are working with temporary tables or real tables, you can have code, where you assume that Record variable is or is not temporary. Best practice is to not assume, but test it to be sure. In history,
|
||||
many developers went through painful period when they did unwanted &ldquo;DeleteAll&rdquo; over real table in production database, because they were only assuming something (mostly it happened only once to them).</p>
|
||||
<p>Therefore it is good practice to use <a href="https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-istemporary-method">Record.IsTemporary()</a> method to test this predicate, mainly when you are doing destructive action.</p>
|
||||
<p>Another case when it is good practice to use this test is when you are subscribing to triggers on table. In most cases, you do not want to run your code when the trigger is running over temporary record. And you cannot assume, that
|
||||
this specific table will not be used as temporary by someone else. Reacting to the trigger as if it was triggered by real table change could lead to corrupted data or unpredictable errors and the reason could be hard to find.</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="display:flex;"><span><span style="color:#f8f8f8;text-decoration:underline"> </span>ShouldBeTemporary<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></span></span></code></pre></div><p>or</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="display:flex;"><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;Some Table&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnAfterInsertEvent&#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></span><span style="display:flex;"><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>DoSomethingOnAfterInsertSomeTable<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;Some Table&#34;<span style="color:#ce5c00;font-weight:bold">)
|
||||
</span></span></span><span style="display:flex;"><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></span><span style="display:flex;"><span><span style="color:#f8f8f8;text-decoration:underline"> </span>DoSomething<span style="color:#ce5c00;font-weight:bold">(</span>Rec<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></span><span style="display:flex;"><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></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="display:flex;"><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>ShouldBeTemporary<span style="color:#ce5c00;font-weight:bold">.</span>IsTemporary<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></span><span style="display:flex;"><span><span style="color:#f8f8f8;text-decoration:underline"> </span>ShouldBeTemporary<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></span></span></code></pre></div><p>or</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="display:flex;"><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>ShouldBeTemporary<span style="color:#ce5c00;font-weight:bold">.</span>IsTemporary<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></span><span style="display:flex;"><span><span style="color:#f8f8f8;text-decoration:underline"> </span>Error<span style="color:#ce5c00;font-weight:bold">(</span>RecNotTemporaryErr<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></span><span style="display:flex;"><span><span style="color:#f8f8f8;text-decoration:underline"> </span>ShouldBeTemporary<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></span></span></code></pre></div><p>or</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="display:flex;"><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;Some Table&#34;<span style="color:#000;font-weight:bold">,</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#39;OnAfterInsertEvent&#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></span><span style="display:flex;"><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>DoSomethingOnAfterInsertSomeTable<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;Some Table&#34;<span style="color:#ce5c00;font-weight:bold">)
|
||||
</span></span></span><span style="display:flex;"><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></span><span style="display:flex;"><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>IsTemporary<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></span><span style="display:flex;"><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></span><span style="display:flex;"><span><span style="color:#f8f8f8;text-decoration:underline"> </span>DoSomething<span style="color:#ce5c00;font-weight:bold">(</span>Rec<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></span><span style="display:flex;"><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></span></code></pre></div></description></item><item><title>Docs: Keyword Pairs - Indentation</title><link>https://alguidelines.dev/docs/bestpractices/keyword-pairs-indentation/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://alguidelines.dev/docs/bestpractices/keyword-pairs-indentation/</guid><description>
|
||||
<p><em>Created by Microsoft, Described by waldo</em></p>
|
||||
<h2 id="description">Description</h2>
|
||||
|
|
|
|||
40
docs/bestpractices/istemporary-table-safeguard/index.html
Normal file
40
docs/bestpractices/istemporary-table-safeguard/index.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue