<?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>Dynamics NAV Try Function Archives - Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</title>
	<atom:link href="http://navsupports.com/tag/dynamics-nav-try-function/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>http://navsupports.com/wp-content/uploads/2018/11/cropped-fav-1-32x32.png</url>
	<title>Dynamics NAV Try Function 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>http://navsupports.com/dynamics-nav-error-handling-using-try-function/</link>
					<comments>http://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="http://navsupports.com/dynamics-nav-error-handling-using-try-function/">Dynamics NAV Error Handling using Try Function</a> appeared first on <a href="http://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="http://navsupports.com/dynamics-nav-error-handling-using-try-function/">Dynamics NAV Error Handling using Try Function</a> appeared first on <a href="http://navsupports.com">Shan Abeywickrama | Dynamics NAV &amp; Business Central Insights</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://navsupports.com/dynamics-nav-error-handling-using-try-function/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
