<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Error Handling Archives - Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</title>
	<atom:link href="https://navsupports.com/tag/error-handling/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Microsoft Dynamics NAV &#124; Business Central</description>
	<lastBuildDate>Wed, 25 Jan 2017 15:50:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.5</generator>

<image>
	<url>https://navsupports.com/wp-content/uploads/2018/11/cropped-fav-1-32x32.png</url>
	<title>Error Handling Archives - Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Dynamics NAV Error Handling using Try Function</title>
		<link>https://navsupports.com/dynamics-nav-error-handling-using-try-function/</link>
					<comments>https://navsupports.com/dynamics-nav-error-handling-using-try-function/#comments</comments>
		
		<dc:creator><![CDATA[Shan Abeywickrema]]></dc:creator>
		<pubDate>Tue, 24 Jan 2017 16:40:35 +0000</pubDate>
				<category><![CDATA[knowledge]]></category>
		<category><![CDATA[Dynamics NAV 2016]]></category>
		<category><![CDATA[Dynamics NAV Try Function]]></category>
		<category><![CDATA[Error Handling]]></category>
		<category><![CDATA[NAV Try Catch]]></category>
		<category><![CDATA[Try Catch]]></category>
		<category><![CDATA[Try Function]]></category>
		<guid isPermaLink="false">http://navsupports.com/?p=138</guid>

					<description><![CDATA[<p>Try Function Dynamics NAV 2016 Today I am going to share very interesting topics on Dynamics NAV 2016. Since year 2012</p>
<p>The post <a href="https://navsupports.com/dynamics-nav-error-handling-using-try-function/">Dynamics NAV Error Handling using Try Function</a> appeared first on <a href="https://navsupports.com">Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2 class="heading" style="text-align: left;">Try Function Dynamics NAV 2016</h2>
<p>Today I am going to share very interesting topics on Dynamics NAV 2016. Since year 2012 I am looking try catch function in Dynamics NAV, I am sure all of Dynamics NAV developers are seeking same function in Dynamics NAV. I notice in Navision 2016 has introduced Try Function to handle errors. Let&#8217;s discuss Dynamics NAV error handling using Try Function.</p>
<p>Try functions in C/AL let you to handle errors that occur in the application during code execution. For instance, with try functions, you can provide user-friendly error messages to the end user than the ugly system messages. You can use try functions to catch exceptions that are thrown by  Dynamics NAV</p>
<p>Important thing you need to be remembered. It does requires that write transactions are committed to the database.</p>
<h2 class="heading">Try Function Behavior and Usage</h2>
<p>Before start you should read NAV Design Patterns Try Function article in MSDN.</p>
<p>To explain this Try Function I will create new codeunit. Create a function called AddCustomer. Parameters should be CustomerNo and CustomerName. CustomerCode should be Code type variable and CustomerName should be Text type variable. Also you need to enable <strong>TryFucntion</strong> <strong>Yes. </strong> Using simple steps you can enable it. Go to properties of <strong>AddCustomer</strong> function then you will find the <strong>TryFunction</strong> property.</p>
<p>After that you need to write few code inside the AddCustomer function and On Run trigger. Let&#8217;s have a look.</p>
<p>LOCAL [TryFunction] AddCustomer(CustomerNo : Code[30];CustomerName : Text[50])<br />
Customer.INIT;<br />
Customer.&#8221;No.&#8221; := CustomerNo;<br />
Customer.Name := CustomerName;<br />
Customer.INSERT;</p>
<p>On Run trigger you can call the AddCustomer function.</p>
<p>OnRun()<br />
//Call AddCustomer Function<br />
CLEARLASTERROR;<br />
IF AddCustomer(&#8216;C02511&#8242;,&#8217;Try Customer Name&#8217;) THEN<br />
MESSAGE(&#8216;Submitted&#8217;)<br />
ELSE<br />
MESSAGE(&#8216;AddCustomer Function has return&#8217; + GETLASTERRORCODE,GETLASTERRORTEXT);</p>
<p>When you run your codeunit. You will get your first message which is Submitted. All fine. When you run it again you will get proper message. Which is AddCustomer Function has return ERROR The Customer already exists. Identification fields and values: No.=&#8217;C02511&#8242; &#8211; DB:RecordExists</p>
<p>Obiously you will get some confusions and you might get some questions. Hope you will post your queries and comments.</p>
<p>The post <a href="https://navsupports.com/dynamics-nav-error-handling-using-try-function/">Dynamics NAV Error Handling using Try Function</a> appeared first on <a href="https://navsupports.com">Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://navsupports.com/dynamics-nav-error-handling-using-try-function/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Better error handling using IF Condition in Dynamics NAV</title>
		<link>https://navsupports.com/better-error-handling-using-condition-dynamics-nav/</link>
					<comments>https://navsupports.com/better-error-handling-using-condition-dynamics-nav/#respond</comments>
		
		<dc:creator><![CDATA[Shan Abeywickrema]]></dc:creator>
		<pubDate>Sun, 08 Jan 2017 18:12:12 +0000</pubDate>
				<category><![CDATA[knowledge]]></category>
		<category><![CDATA[Dynamics NAV]]></category>
		<category><![CDATA[Error Handling]]></category>
		<category><![CDATA[IF Condition]]></category>
		<category><![CDATA[Navision]]></category>
		<guid isPermaLink="false">http://navsupports.com/?p=101</guid>

					<description><![CDATA[<p>Hello guys, I would like to share some important tips with you and sometime you might known these tips also</p>
<p>The post <a href="https://navsupports.com/better-error-handling-using-condition-dynamics-nav/">Better error handling using IF Condition in Dynamics NAV</a> appeared first on <a href="https://navsupports.com">Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hello guys, I would like to share some important tips with you and sometime you might known these tips also you love C/AL coding and you would hate this area, which is error handling. So Let&#8217;s have a look of better error handling in Dynamics NAV</p>
<p>So may be you love if we have <strong>Try Catch</strong> statement to capture the errors. But we can have simple way to handle some error,</p>
<p>Mostly we are facing run time errors. For instance , you will have a calculation like  <em><strong>AvgAmt := LineAmt / TotalValue  </strong></em>,What happens if TotalValue is zero ? Yes of course you will get an error which may you mostly familiar <em><strong>Divided by zero</strong></em> error.</p>
<p>So how we are going to handle these type of run time errors, Let me tell you some interesting thing, You can use IF condition to handle this type of errors, For instance, simply you can check if the Totavalue is 0 or not. If it is not 0 you can allow the calculation else you can  assign default value to the TotalValue. Here is the example,</p>
<p>IF TotalValue &lt;&gt; 0 THEN<br />
<em><strong>    AvgAmt := LineAmt / TotalValue</strong></em><br />
ELSE<br />
AvgAmt := 0;</p>
<p>Sometimes you may have used GET Function to retrieve values. You already know how to use  GET Function, But sometime you will get error, for instance, <em><strong>Customer &#8220;&#8221; does not exist  </strong></em>something smiler to this, So what we have to do is we need to keep the get function with IF condition.</p>
<p>IF NOT (Customer.GET(&#8220;C001&#8221;)) THEN CLEAR(Customer);</p>
<p>So now you know, using simple IF condition we can handle run time errors  in some area in Dynamics NAV.</p>
<p>&nbsp;</p>
<p>The post <a href="https://navsupports.com/better-error-handling-using-condition-dynamics-nav/">Better error handling using IF Condition in Dynamics NAV</a> appeared first on <a href="https://navsupports.com">Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://navsupports.com/better-error-handling-using-condition-dynamics-nav/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
