<?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>Doens.be &#187; Best Practice</title>
	<atom:link href="http://www.doens.be/tag/best-practice/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.doens.be</link>
	<description></description>
	<lastBuildDate>Sat, 07 Jan 2012 04:20:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Best Practices &#8211; Technical Best Practices for Dynamics AX</title>
		<link>http://www.doens.be/2010/06/best-practices-technical-best-practices-for-dynamics-ax/</link>
		<comments>http://www.doens.be/2010/06/best-practices-technical-best-practices-for-dynamics-ax/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 05:00:22 +0000</pubDate>
		<dc:creator>Jeroen Doens</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[RE-Blog]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.doens.be/?p=619</guid>
		<description><![CDATA[While surfing on the web about Ax Best-Practices I found the following link on Packt Publishing. I think this is a verry good list of things a Ax developer should do while programming. This article is a part of the book &#8216;Quality Assurance for Dynamics AX-Based ERP Solutions&#8216;, maybe I&#8217;ll read it. If the link [...]]]></description>
			<content:encoded><![CDATA[<p>While surfing on the web about Ax Best-Practices I found the following <a href="https://www.packtpub.com/article/technical-best-practices-for-dynamics-ax-shared-and-aot-object-standards" target="_blank">link</a> on Packt Publishing. I think this is a verry good list of things a Ax developer should do while programming.</p>
<p>This article is a part of the book &#8216;<a href="https://www.packtpub.com/quality-assurance-for-dynamics-ax-based-erp-solutions" target="_blank">Quality Assurance for Dynamics AX-Based ERP Solutions</a>&#8216;, maybe I&#8217;ll read it.</p>
<p><span id="more-619"></span></p>
<p>If the link to the article is broken (source <a href="https://www.packtpub.com">Packt Publishing</a>) :</p>
<blockquote>
<h1>Shared Standards</h1>
<p>Some Dynamics AX customization best practices are applicable irrespective of AOT element. These standards include X++ standards, naming conventions, label standards, and Help Text guidelines.</p>
<h2>X++ Standards</h2>
<p>This section discusses some best practices related to the X++ language. Conformance to this standard results in improved execution time, ease in upgrading and further customization, efficient use of OOP concepts, better readability of code, etc. Some general principles are as follows:</p>
<ul>
<li>Variable or constant or parameter declarations should be as local as possible to utilize memory resources in an efficient way.</li>
<li>Error conditions should be checked in the beginning so that minimum work is done for action and rollback of action. This will also hinder denial of service attacks. Denial of service attack is an attempt to stress the system with too many garbage requests so that an authorized user is not served.</li>
<li>The parameters supplied as value must not be modified or manipulated as it may increase the chances of using wrong values somewhere else.</li>
<li>Code should be written in a clean fashion, which means unused variables, methods, and classes should be removed from the code.</li>
<li>The existing MorphX functions or functionality should be used as much as possible (unless other best practices stop you from doing so), rather than creating new ones as it will make upgrading easier.</li>
<li>The user should not experience a run-time error. All possible cases should be foreseen and handled accordingly. If some unpredicted case appears during run time, it should show an error in the Infolog with a message to help the users on how to avoid the situation and what action can be taken to prevent it.</li>
<li>The value of the this variable should not be changed.</li>
<li>The reusability should be maximized. E.g. rather than repeating lines of code at different places, a single method can be written so that changes in the method can be reflected at all the places where this method is used.</li>
<li>There should be only one successful return point (except in switch statements) so that object deletion, etc. can be ensured.</li>
<li>A method should perform a single well-defined task and be named according to the task performed.</li>
</ul>
<h3>Text Constant Standards</h3>
<p>All the text used in Dynamics AX is supposed to be in a label file irrespective of its use e.g. user interface or error or success message. The use of text constants can be classified into two broad categories i.e. user interface text and system-oriented text.</p>
<p>The text used in the user interface should follow the following best practices:</p>
<ul>
<li>Modify property values on the extended data types or base enums inthe application.</li>
<li>Never create duplicate label files i.e. the same text (in the same language) but a different label file.</li>
<li>New label files can be created when customizing the text, but it is always recommended to reuse the standard labels. However, it may offer a disadvantage—all the changes made to the SYS layer label files will be gone whenever an upgrade occurs. So the decision of customizing an existing label file or creating new label file should be taken carefully.</li>
<li>User interface text (labels files) should be used in double quotes.</li>
</ul>
<p>System-oriented text constants must be in single quotes.</p>
<h3>Exception Handling</h3>
<p>The principle uses of exception handling include freeing system resources (e.g. memory through object deletion, closing database connection, etc.) and providing constructive information in the Infolog so that the user can prevent such erroneous conditions. The following are a few recommended best practices related to exception handling:</p>
<ul>
<li>A try or catch deadlock or retry loop should always be created around database transactions that can cause deadlocks.</li>
<li>In the retry clause the values of transient variables should be set back to the values before try.</li>
</ul>
<h3>Branching</h3>
<p>A few recommended best practices related to the if-else statement and switch statement are as follows:</p>
<ul>
<li>Always use positive logic e.g. write if (true) rather than if (! false).</li>
<li>Prefer switch statement rather than multiple if-else statements.</li>
<li>Always end a case with a break or return or throw statement unless a fall through mechanism is intentionally used. When a fall through mechanism is used a comment should be given like //fall through so that it is clear to every reader.</li>
</ul>
<h3>Code Layout</h3>
<p>For readability of the code, code should be written in a proper layout. Some chief best practices for code layout are as follows:</p>
<ul>
<li>Remove commented code before shipping code.</li>
<li>Follow indentation rules.</li>
<li>Follow case rules for naming classes, methods, tables, etc.</li>
</ul>
<h3>Methods</h3>
<p>Following are a few best practices for methods:</p>
<ul>
<li>Methods should be small and logical so that it can be easily overridden or over-layered.</li>
<li>Methods should perform a single well defined task and from their name the task performed should be clear.</li>
<li>For static class methods and table methods, qualified client, server, or client server should be used in such a way that calls to other tiers are minimized. For greater details refer to the Best Practices for Designing section in the Developer&#8217;s Guide.</li>
<li>To ensure trustworthiness, appropriate access levels (public, private, or protected) should be assigned.</li>
<li>Methods should be named according to the Dynamics AX naming conventions; the reserved keywords such as is, check, validate, set, get, and find should be used as per the Dynamics AX way of using these standard methods or functions. All methods using such keywords must not have side effects e.g. no assignment in validate, check, get, or is methods.</li>
<li>Parameter&#8217;s names must start with an underscore (_) character besides following other generalized naming conventions.</li>
</ul>
<h3>Handling Dates</h3>
<p>Dates are sources of error due to variations in date presentation formats and in values due to differences in time zone. A few best practices for handling dates are as follows:</p>
<ul>
<li>Date fields must be stored or displayed in the date field only as IntelliMorph has the ability to display the date value in a format suitable for the user provided that the date format property is chosen as Auto and it is presented in a date control.</li>
<li>The system date should not be considered as reliable information but in some cases (e.g. validation of information input by a user) system date should be read using the SystemDateGet() function instead of the today() function.</li>
<li>Date conversion should be avoided as it will loose date properties and hence sometimes conversion may result in wrong information. For all user interface-related situations strFmt or date2Str should be used with a value of -1 for all formatting-related parameters. This will allow users to use this information in the format specified in regional settings. Care should also be taken that string variables storing converted date information are sufficiently long.</li>
</ul>
<h2>Label Standards</h2>
<p>It is highly recommended that any user-interface text is defined using labels. This will ensure many advantages during translation. A few label file standards to ensure the true benefits of the label file system are as follows:</p>
<ul>
<li>The location of label files should be the most generalized one i.e. extended data type (EDT). In some cases an existing EDT cannot be used only because of the difference in label text. In such cases a new EDT should be created by extending the existing EDT. In such cases other alternatives may also be available (e.g. label change at the field) but the rule of thumb is to use the label at the most general place.</li>
<li>The label files should not be duplicated i.e. two label files should not exist for the same text.</li>
</ul>
<h1>AOT Object Standards</h1>
<p>The AOT object standards are specific to a particular AOT element. Broadly we can classify AOT elements as follows:</p>
<ul>
<li>Data Dictionary
<ul>
<li>Extended data type</li>
<li>Base Enum</li>
<li>Tables</li>
<li>Feature keys</li>
<li>Table collection</li>
</ul>
</li>
<li>Classes</li>
<li>Forms</li>
<li>Reports</li>
<li>Jobs</li>
<li>Menu items</li>
</ul>
<h2>Data Dictionary</h2>
<p>This is a group of AOT objects including the items mentioned in the previous section. The best practices for tables can further be divided into best practices for the fields, field groups, indexes, table relations, delete actions, and methods.</p>
<h3>Extended Data Type</h3>
<p>The EDT plays a great role as it is the basic entity of GUI elements. The following are a few basic best practices related to extended data types.</p>
<ul>
<li>All date and date format-related properties should be set to <strong>Auto</strong>.</li>
<li>Help text should not be same as the label property. Help text is supposed to be more descriptive and should be able to explain why and/or how.</li>
<li>An EDT name must be a real-world name, prefixed with module (if it belongs to one module only).</li>
</ul>
<h3>Base Enum</h3>
<p>The following are a few basic best practices related to Base Enum:</p>
<ul>
<li>The Enum name should be an indication of either the few possible values or type of values. For example DiscountType, OpenClose, etc.</li>
<li>Display length property should be set to auto so that in every language the full name can be displayed.</li>
<li>Help and label properties must have some value. Help and label properties should not have the same value.</li>
</ul>
<h3>Tables</h3>
<p>Many of the best practices for tables come under the scope of performance optimization, database design standards, etc. and hence those standards have been discussed elsewhere. Some of the standards not discussed are discussed here.</p>
<ul>
<li>The table name may consist of the following valuable information:
<ul>
<li><strong>Prefix</strong>: Module name such as Cust for Account Payable, Sales for Account Receivables</li>
<li><strong>Infix</strong>: Logical description of the content</li>
<li><strong>Post fix</strong>: Type of data e.g. Trans (for transactions), Jour (Journals), Line (table containing detailed information about a particular record in header table), Table (primary main tables), Group, Parameters, Setup, or module name to which the table belongs</li>
</ul>
</li>
<li>Label is a mandatory property and tables must be labelled using Label ID only. The text value of Label ID must be unique in all languages supported.</li>
<li>If a table belongs to one of the four types Parameter, Group, Main, or WorksheetHeader, then it must have an associated form to maintain the table records. This form should have a name identical to its display menu item (used to start this form) and like the table name. formRef is the property of a table for the name of the associated form.</li>
<li>Title Field 1 and Title Field 2 should be mentioned:
<ul>
<li><strong>TitleField1</strong>: The key field for the records in the table. This should be a descriptive title, if the key is information for the user.</li>
<li><strong>TitleField2</strong>: The description for the records in the table.</li>
</ul>
</li>
</ul>
<h4>Fields</h4>
<p>Most of the properties for the fields are inherited from extended data types; however, it is not mandatory to use some or all inherited values for such properties. Here are a few guidelines:</p>
<ul>
<li>Name: Should be like the corresponding EDT name but if named separately, it should be logical. The fields used as key should be postfixed as ID e.g. CustId, ItemId, etc.</li>
<li>HelpText: This is a mandatory property and inherited from the corresponding EDT. Since Help Text needs to be customized as per the different uses ofthe same EDT, Help text can be modified at any field but the following arethe guidelines:
<ul>
<li>The help text property should not be same as the label property.</li>
<li>Label is also a mandatory property, which is inherited from EDT. If a value is set here, it should be different from the value on EDT.</li>
<li>Every field that is either the primary key or one of the key mandatory properties must be set to <strong>Yes</strong>.</li>
<li>Before considering memo or container type fields, it should be kept in mind that they add time to application and database fetch, they inhibit array fetching, and these types of fields cannot be used in where expressions.</li>
</ul>
</li>
</ul>
<h4>Field Group</h4>
<p>The field group is a group of fields shown in the user interface. Dynamics AX has some standard groups (e.g. Identification, Administration, Address, Dimension, Setup, Misc, etc.), while other can be created. The fields that logically belong together can be placed in one field group while the Misc field group can be used to group fields that do not fit in any other field group. The dimension field group must have a single kind of field <strong>Dimension</strong>. The field groups should have the same kind of grouping at the database and form or reports to improve caching and hence the performance.</p>
<h4>Delete Actions</h4>
<p>The database integrity is one of the key principles in Relational Database Management System (RDBMS). The delete action should be used on every relation between two tables. The following are key best practices for delete actions.</p>
<ul>
<li>Use a delete action on every relation between two tables.</li>
<li>Use table delete actions instead of writing code to specify whether deletes are restricted or cascaded.</li>
</ul>
<p>Dynamics AX has three types of delete actions; selection of one will solely depend upon the custom requirements.</p>
<h4>Table Methods</h4>
<p>The tables in Dynamics AX have several properties such as delete, validateDelete, etc. and hence Dynamics AX recommends that you should not write methods or X++ code to implement something that can be done just by setting property values.</p>
<p>Dynamics AX recommends using inbuilt table methods for those custom requirements that cannot be met with table properties settings. Some of the table methods are mandatory to implement e.g. find and exists methods.</p>
<h2>Classes</h2>
<p>The classes have a peculiarity that they may have both a back end (database) and front end (GUI). The front interface should be easy to use and at the same time as secure as possible. The implementation details of the class should always be hidden from the user and hence use of private or protected methods is recommended. The back-end methods are highly secure, standardized, and reliable and hence use of private or protected methods is recommended in prescribed design patterns. The design patterns depend upon the type of class. Classes can be categorized in the following categories:</p>
<ul>
<li>Real object</li>
<li>Action class</li>
<li>Supporting class</li>
</ul>
<p>The following are a few common best practices related to declaration:</p>
<ul>
<li>Object member variables must only be used to hold the state of the object i.e. variables for which values should be kept between and outside instance method calls.</li>
<li>Use of global variables must be minimized.</li>
<li>Unused variables must be cleaned up; a tool available at <strong>Add-Ins | Best Practices | Check Variables</strong> can be used to know the unused variables.</li>
<li>Constants used in more than one method in a class (or in subclass) should be declared during class declaration.</li>
</ul>
<p>There is a rich set of best practices for classes and the Best Practices for Microsoft Dynamics AX Development released by Microsoft would be good read.</p>
<h2>Forms</h2>
<p>The forms are in the presentation tier in any three-tier architecture system. Most of them are related to look and feel or layout. Some other best practices for forms revolve around the following characteristics:</p>
<ul>
<li>Use of Intellimorph maximally</li>
<li>No forced date or time format</li>
<li>No forced layout such as fixed width for label, position control for GUI controls, etc.</li>
<li>Use of label files for GUI text</li>
<li>Forms having minimal coding</li>
</ul>
<h3>Avoid Coding on Forms</h3>
<p>The basic concept of three-tier architecture is that forms should be used only for the presentation tier and hence no other code such as business logic should be there on forms. The code placed on forms also reduces their reusability and the ease of further customization; e.g. if you want to develop an enterprise portal, the code written on forms will have to be written again in classes or table methods, etc., which will make the implementation complex. Another example may be when you want to &#8216;COM enable&#8217; your business logic; form code related to business logic will make your life almost impossible.</p>
<p>Any code (other than presentation logic) written on forms imposes limitation on performance as call between two different layers increase slowing the performance and hence code on forms should be avoided as much as possible. In cases where avoiding code on forms is not possible the guidelines summarized in the following table should be used for writing code on forms.</p>
<table border="1" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td width="172" valign="top"><strong>Place to Write Code</strong></td>
<td width="304" valign="top"><strong>Guidelines</strong></td>
</tr>
<tr>
<td width="172" valign="top">Form level</td>
<td width="304" valign="top">When code is related to whole formWhen code is related to multiple data sourcesEditor or Display methods (only those that are not related to any data source)</td>
</tr>
<tr>
<td width="172" valign="top">Data source</td>
<td width="304" valign="top">Data source-related Edit or Display methodsCode related only to the data source that cannot be effectively placed in a table method</td>
</tr>
<tr>
<td width="172" valign="top">Controls</td>
<td width="304" valign="top">When it is strictly related to the controls</td>
</tr>
</tbody>
</table>
<h3>Use of IntelliMorph Maximally</h3>
<p>Due to a user&#8217;s locale or preferred format a form may be presented in a different language and/or a different date, time, or currency format. Dynamics AX best practices recommend <strong>Auto</strong> as the value for the display properties related to the following:</p>
<ul>
<li>Date</li>
<li>Currency</li>
<li>Time</li>
<li>Language</li>
<li>Number format (such as decimal operator, separator, etc.)</li>
<li>Label size</li>
<li>Form size</li>
</ul>
<p>The rule of thumb is to keep the various properties as <strong>Auto</strong> or default value, which will help IntelliMorph to function maximally. For further details about best practices readers are recommended to go through the Developers Guide for Best Practices.</p>
<h2>Reports</h2>
<p>The peculiar fact about the reports is that they are output media where the external environment such as paper size, user&#8217;s configuration about the locale or language, font size, etc. matters.</p>
<p>Dynamics AX recommends using &#8216;Auto Design&#8217; to develop the report as these kinds of reports can change the layout according to external environmental variables. Another way to develop a report in Dynamics AX is &#8216;Generated Design&#8217;; this type of design is recommended only when strict report layout is required. A few such examples may be regulatory reports, accounts reports, etc.</p>
<h1>Summary</h1>
<p>In this two part article we discussed various areas where quality could be improved by adopting best practices. We also discussed various best practices, theory behind best practices, and how to adopt these best practices, i.e. with practical tips.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.doens.be/2010/06/best-practices-technical-best-practices-for-dynamics-ax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Ax Infolog</title>
		<link>http://www.doens.be/2010/05/the-ax-infolog/</link>
		<comments>http://www.doens.be/2010/05/the-ax-infolog/#comments</comments>
		<pubDate>Fri, 07 May 2010 05:00:25 +0000</pubDate>
		<dc:creator>Jeroen Doens</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Infolog]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[User interaction]]></category>
		<category><![CDATA[X++]]></category>

		<guid isPermaLink="false">http://www.doens.be/?p=535</guid>
		<description><![CDATA[Wel all know the small dialog that gives the user usefull information about what is happening in Ax. In this post I will tell u some more about this. You can add information to the Infolog by calling: Infolog.add(&#8230;) info(&#8230;) warning(&#8230;) or checkfailed(&#8230;) error(&#8230;) You can add some structure in it by using setPrefix(&#8230;) Using [...]]]></description>
			<content:encoded><![CDATA[<p>Wel all know the small dialog that gives the user usefull information about what is happening in Ax. In this post I will tell u some more about this.</p>
<p>You can add information to the Infolog by calling:</p>
<ul>
<li>Infolog.add(&#8230;)</li>
<li><a href="http://www.doens.be/wp-content/uploads/2010/05/icon_info.gif"><img class="alignnone size-full wp-image-536" title="icon_info" src="http://www.doens.be/wp-content/uploads/2010/05/icon_info.gif" alt="" width="17" height="14" /></a> info(&#8230;)</li>
<li><a href="http://www.doens.be/wp-content/uploads/2010/05/icon_warning.gif"><img class="alignnone size-full wp-image-537" title="icon_warning" src="http://www.doens.be/wp-content/uploads/2010/05/icon_warning.gif" alt="" width="17" height="16" /></a> warning(&#8230;) or checkfailed(&#8230;)</li>
<li><a href="http://www.doens.be/wp-content/uploads/2010/05/icon_error.gif"><img class="alignnone size-full wp-image-538" title="icon_error" src="http://www.doens.be/wp-content/uploads/2010/05/icon_error.gif" alt="" width="15" height="14" /></a> error(&#8230;)</li>
<li>You can add some structure in it by using setPrefix(&#8230;)</li>
<li>Using the Proxy-class for the Enterprise Portal</li>
</ul>
<p><a href="http://www.doens.be/wp-content/uploads/2010/05/infolog_FirstExample.png"><img class="alignnone size-full wp-image-545" title="infolog_FirstExample" src="http://www.doens.be/wp-content/uploads/2010/05/infolog_FirstExample.png" alt="" width="348" height="344" /></a><br />
<span id="more-535"></span><br/><br />
The <strong>info</strong>(), <strong>warning</strong>() and <strong>error</strong>() method are found in the Global class and can contain up to 3 arguments:</p>
<ul>
<li>a string <em>(mandatory) </em>: the string that is added to the infolog</li>
<li>a path to the Axapta Help <em>(optional)</em></li>
<li>an Infolog action <em>(optional)</em> : you can use this parameter to initiate a action, for example open the code editor or open a parameter-form when some parameters are missing. Depending on what action you want to trigger, you need to call the right method that extend from sysInfoAction.</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="xpp" style="font-family:monospace;">SysInfoAction   sysInfoAction;
;
sysInfoAction <span style="color: #00007f;">=</span> SysInfoAction_Formrun<span style="color: #00007f;">::</span><span style="color: #000000;">newFormname</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">formstr</span><span style="color: #000000;">&#40;</span>HRMParameters<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
info<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;click on me&quot;</span><span style="color: #00007f;">,</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #00007f;">,</span> sysInfoAction<span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p><a href="http://www.doens.be/wp-content/uploads/2010/05/infolog_clickOnme.png"><img class="alignnone size-full wp-image-546" title="infolog_clickOnme" src="http://www.doens.be/wp-content/uploads/2010/05/infolog_clickOnme.png" alt="" width="348" height="344" /></a><br />
<br/><br />
Using the keyword <strong>Throw </strong>before info(), error() or warning will result in terminating the execution (or jump to catch statement) and a rollback of your transactions.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xpp" style="font-family:monospace;"><span style="color: #0000ff;">throw</span> error<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;Something bad happend&quot;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p><a href="http://www.doens.be/wp-content/uploads/2010/05/infolog_throwerror1.png"><img class="alignnone size-full wp-image-554" title="infolog_throwerror" src="http://www.doens.be/wp-content/uploads/2010/05/infolog_throwerror1.png" alt="" width="348" height="323" /></a><br />
<br/><br />
The method <strong>setPrefix</strong>() will help you to group info(), warning() and error() messages with a header. using setPrefix() will make a indentation for your current block of code <em>(everything between { and }).</em> Leaving the code-block will automatically result in going one indentation back.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="xpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> i;
<span style="color: #0000ff;">int</span> j;
;
<span style="color: #0000ff;">setPrefix</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;Testing out setPrefix&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span>i<span style="color: #00007f;">=</span><span style="color: #000000;">1</span> ; i<span style="color: #00007f;">&amp;</span>lt;<span style="color: #00007f;">=</span><span style="color: #000000;">2</span> ; i<span style="color: #00007f;">++</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0000ff;">setPrefix</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">strfmt</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;Prefix %1&quot;</span><span style="color: #00007f;">,</span> i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span>j<span style="color: #00007f;">=</span><span style="color: #000000;">1</span> ; j<span style="color: #00007f;">&amp;</span>lt;<span style="color: #00007f;">=</span><span style="color: #000000;">3</span> ; j<span style="color: #00007f;">++</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		info<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">strfmt</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;Info %1&quot;</span><span style="color: #00007f;">,</span> j<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><a href="http://www.doens.be/wp-content/uploads/2010/05/infolog_setPrefic.png"><img class="alignnone size-full wp-image-547" title="infolog_setPrefic" src="http://www.doens.be/wp-content/uploads/2010/05/infolog_setPrefic.png" alt="" width="348" height="403" /></a><br />
<br/><br />
The <strong>checkFailed</strong>() method is a warning() method that returns a Boolean (alwais false). U can use this method when you want to display a warning and directly set a return value to false.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xpp" style="font-family:monospace;"><span style="color: #0000ff;">Boolean</span> ret;
;
<span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">true</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    ret <span style="color: #00007f;">=</span> checkFailed<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;Something is wrong&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0000ff;">return</span> ret;</pre></td></tr></table></div>

<p><a href="http://www.doens.be/wp-content/uploads/2010/05/infolog_checkFailed.png"><img class="alignnone size-full wp-image-558" title="infolog_checkFailed" src="http://www.doens.be/wp-content/uploads/2010/05/infolog_checkFailed.png" alt="" width="348" height="323" /></a><br />
<br/><br />
<strong>Note:</strong> The infolog can contain <strong>maximum 10000 lines</strong>. So try to limit the use of it. Building the output of the infolog usually happens at the end of the code you are executing and depending on the number of lines, it can take a while. You can limit the maximum number of lines under a header in a batch by setting the property<strong> infolog.errorsPerBatch(#)</strong>(). When this number is exceeded only the furst # will appear and Ax will give you a notification that their could be more errors.<br />
It is also possible to update the infolog while executing code by calling the method<strong> infolog.viewUpdate</strong>().<br />
<br/><br />
<strong>Using the infolog in the Enterprise Portal:</strong><br />
In the portal you can access the infolog by using the Proxy of the Enterprise Portal.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;
Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter);</pre></td></tr></table></div>

<p>Now, when you want to write something to the infolog you need to give a Enum with it, so the portal knows if the message you want to show is a info, warning or error. So pass through Proxy.Exception.Info, Proxy.Exception.Warning or Proxy.Exception.Error.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">objInfoLog.add(Proxy.Exception.Warning, &quot;My warning&quot;);</pre></td></tr></table></div>

<p><br/><br />
So in short thing you should <strong>keep in mind</strong> while using the Infolog-class:</p>
<ul>
<li>Use short &#038; informative messages</li>
<li>Choose the righty message level (info, warning, error)</li>
<li>Use actions, this simple trick is verry usefull for end-users</li>
<li>Limit the number of messages you send to the Infolog-dialog</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.doens.be/2010/05/the-ax-infolog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tip for overriding methods</title>
		<link>http://www.doens.be/2010/04/tip-for-overriding-methods/</link>
		<comments>http://www.doens.be/2010/04/tip-for-overriding-methods/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 05:00:44 +0000</pubDate>
		<dc:creator>Jeroen Doens</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[X++]]></category>

		<guid isPermaLink="false">http://www.doens.be/?p=486</guid>
		<description><![CDATA[There is a simple and generic way to force overriding a method you created. To do so you just need create your new method and place a &#8216;throw error&#8217; statement in it. To finish you can add the static method missingOverride from the error class and the funcName() to your error. Now when this method [...]]]></description>
			<content:encoded><![CDATA[<p>There is a simple and generic way to force overriding a method you created. To do so you just need create your new method and place a &#8216;throw error&#8217; statement in it. To finish you can add the static method missingOverride from the<a href="http://msdn.microsoft.com/en-us/library/aa576695%28v=AX.50%29.aspx" target="_blank"> error class</a> and the funcName() to your error. Now when this method is called or the super() in you child class is called, you will get a error that you need to override your method.</p>

<div class="wp_syntax"><div class="code"><pre class="xpp" style="font-family:monospace;"><span style="color: #0000ff;">public</span> identifiername myMethod<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">throw</span>  error<span style="color: #000000;">&#40;</span>Error<span style="color: #00007f;">::</span><span style="color: #000000;">missingOverride</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">funcName</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>When you use this peace of code you will get the following error:<br />
<a href="http://www.doens.be/wp-content/uploads/2010/04/overrideMethod.png"><img class="size-full wp-image-488 alignnone" title="Missing Override Method" src="http://www.doens.be/wp-content/uploads/2010/04/overrideMethod.png" alt="" width="346" height="312" /></a></p>
<p><strong>Note: </strong>The error-class also has some other usefull static methods like: <a href="http://msdn.microsoft.com/en-us/library/aa573466%28v=AX.50%29.aspx">missingFormActiveBuffer</a>, <a href="http://msdn.microsoft.com/en-us/library/aa615299%28v=AX.50%29.aspx">missingOverload</a>, <a href="http://msdn.microsoft.com/en-us/library/aa849831%28v=AX.50%29.aspx">missingOverride</a>, <a href="http://msdn.microsoft.com/en-us/library/aa603172%28v=AX.50%29.aspx">missingParameter</a>, <a href="http://msdn.microsoft.com/en-us/library/aa625579%28v=AX.50%29.aspx">missingRecord</a> and my favorite <a href="http://msdn.microsoft.com/en-us/library/aa852215%28v=AX.50%29.aspx">wrongUseOfFunction</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.doens.be/2010/04/tip-for-overriding-methods/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Working with numbersequences – Keep In Mind</title>
		<link>http://www.doens.be/2010/02/working-with-numbersequences-%e2%80%93-keep-in-mind/</link>
		<comments>http://www.doens.be/2010/02/working-with-numbersequences-%e2%80%93-keep-in-mind/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 17:00:54 +0000</pubDate>
		<dc:creator>Jeroen Doens</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[Ax 4.0]]></category>
		<category><![CDATA[Ax 5.0 (2009)]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Number Sequence]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.doens.be/?p=349</guid>
		<description><![CDATA[When you are using a Number Sequence, keep in mind that a Continuous Number Sequence is slower than a non-continuous. The reason is that the system creates a record in the table NumberSequenceList (with the status Active) and cleans it up later during TTSCOMMIT. Performance tip: You can improve the performance of a process that creates many [...]]]></description>
			<content:encoded><![CDATA[<p>When you are using a <a href="http://www.doens.be/tag/numbersequence/">Number Sequence</a>, keep in mind that a Continuous Number Sequence is slower than a non-continuous. The reason is that the system creates a record in the table NumberSequenceList (with the status Active) and cleans it up later during TTSCOMMIT.</p>
<p><strong>Performance tip:</strong> You can improve the performance of a process that creates many numbers of one Number Sequence by using number pre-allocation. This loads a set of numbers into the memory and provides faster access. You can do this by using the NumberSeqGlobal, witch means that once it is instantiated, it is available until the session is closed. This function is only available for non-continuous Number Sequences. The numbers can only be retrieved from the cache by calling the getNumInternal() method in the NumberSeq_Fast class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doens.be/2010/02/working-with-numbersequences-%e2%80%93-keep-in-mind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Placement of code</title>
		<link>http://www.doens.be/2010/02/placement-of-code/</link>
		<comments>http://www.doens.be/2010/02/placement-of-code/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 17:00:32 +0000</pubDate>
		<dc:creator>Jeroen Doens</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[Ax 4.0]]></category>
		<category><![CDATA[Ax 5.0 (2009)]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[X++]]></category>

		<guid isPermaLink="false">http://www.doens.be/?p=319</guid>
		<description><![CDATA[When you are programming, you have to think about where placing you&#8217;re code. Always try to place you&#8217;re code nearest to the source so it can be manipulated easily. For instance code that manipulates tables should be placed in that tables methods. Best Practice: Try to minimize the x++ code in forms for the following [...]]]></description>
			<content:encoded><![CDATA[<p>When you are programming, you have to think about where placing you&#8217;re code. Always try to place you&#8217;re code nearest to the source so it can be manipulated easily. For instance code that manipulates tables should be placed in that tables methods.</p>
<p><strong>Best Practice:</strong> Try to minimize the x++ code in forms for the following reasons:</p>
<ul>
<li>Forms do not support inheritance. You cannot share logic implemented in a form with other application objects.</li>
<li>The X++ code implemented in forms is always executed on the client. This means that you cannot tune an application by specifying where to execute the code.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.doens.be/2010/02/placement-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

