Thursday, November 17, 2011

Naming Conventions in Microsoft Dynamics AX

Hi there!

I remember when I started developing software ... oh man, time goes fast as it was many years ago. In my first job I had a manager that would always reminded me to create clear naming conventions for my objects. He believed this was the base for any software development design as they were really important when scaling up an existing application. Yes, he was right!

Later in my life I started working in bigger teams, and one of the things that caught my attention in these environments was the fact that there were many developers that didn't care about creating consistent naming conventions when writing code.

Yes, this is horrible and makes it hard for the person who is later maintaining or scaling up the system.

There is a great quote about this:

“ Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ” - Rick Osborne 

Luckily we don't have to work under the pressure that a psychopath will come to our homes at night if we don't write good naming conventions...But, what about the customer and/or employer who trusts us in doing a professional job?

To be honest with you, I think that dealing with a psychopath is much easier than dealing with an unhappy customer ... They support our lifestyle!

When I started working with Microsoft Dynamics AX, I rapidly understood the importance of getting into the habit of writing well defined naming conventions as the application objects are not only data types and classes (in the case of early languages), but tables, enums, macros, forms, data sets, queries, menu items, services, etc.

In addition, naming conventions contribute to consistency and to making the application easier to understand. I think that the basic rule to create good naming conventions is to do it from three basic components:
{business area name} + {business area description} + {action performed (for classes) or type of contents (for tables)}
• CustJournalPrintOutInvoice
• PriceDiscAdmDelete
• PriceDiscAdmSearch
• PriceDiscAdmName
• PriceDiscAdmTrans

Also, take into consideration the following:
• All names must be in U.S. English.
• The default rule is to use logical and descriptive names if no other specialized rules apply.
• Identifier names have a limit of 40 characters.
• Names must be spelled correctly.
• Names must be used consistently.
• All texts that appear in the user interface must be defined by using a label.
• Do not begin a name with nonsensical or confusing prefixes, such as "aaa" or "CopyOf".
• Do not begin a name with "DEL_" unless it is a table, extended data type or enum, and it is needed for data upgrade purposes - doing this may cause unexpected results.

As you can see, by following these simple rules, we can start making a big difference in our code. Let's get into the habit ... otherwise the psychopath will get you!

Take care!

Wednesday, November 16, 2011

Configuring and running the AX 2012 Hyper-V image with VirtualBox


A while ago I started setting up the AX 2012 virtual box in my laptop. It took me a few days to download and have everything ready to start setting the machine up. However, when I finally found the time to install it, I got a few errors on virtual PC . As a result I was unable to boot the machine successfully due to a file corruption error.

The following is a link that helped me out in fixing a few issues.

A few days later I found a video (below) that explained on how to install AX 2012 Hyper-V using the Oracle VM. After following the video (really easy to understand) I was able to successfully run AX 2012 VM on my computer.

NOTE: You will need access to partner source to download the AX 2012 VM files.

Check it out

Take care!

Inside Microsoft Dynamics AX 2012 Performance

Hi there!
I found a very interesting video on AX 2012 performance. It is amazing and really exciting to be part of this release as there have been many improvements to create a better, more reliable and faster product. The following are the key points in the video:
1-   Ax 2012 focuses its efforts on the AOS, this is, the AOS can scale up and scale out.  For example, as computer manufactures create bigger boxes (strong processing power), AX 2012 application server scales out to take full advantage of this new advances.
2-    Ax 2012 takes the unmanaged X++ and run it in .NET. Therefore X++ is now a managed language which means is faster (way faster than before!)
3-    There has been a lot of work done towards space optimization. For instance, in retail situations the number of transactions can quickly grow, and this data needs to be stored efficiently without increasing storage costs.
4-    Transactions are much faster thanks to the improvements in X++ compatibility with .NET. For example, in AX 2009 you could run 100 lines of code in X amount of time (X being a number of seconds). In AX 2012 you can run 1,000 lines of code in the amount of time (X) that AX 2009 does.  This helps achieving fast deployments and customer usability of the product.
5-    The goal of AX 2012 is increase transaction speed and customer satisfaction by implementing the solution on pretty much the same hardware an end user had before.
Check it out.

Take care!

Thursday, November 10, 2011

Debug X++ code in a Batch Server in AX 2009

Hi there!

Today I would like to discuss how to debug X++ code in a batch server. One of the common scenarios in AX development is the debugging of X++ code in the client.

For example, if you want to debug the SalesFormLetter class after posting either a Packing Slip or an Invoice, you just would go to the AOT > Classes>SalesFormLetter look for the method you want to debug and add a breakpoint. Simple!

In AX 2009, however, we have the ability to run Batch jobs directly on the server (unlike prior versions (i.e. 3.5)). The problem is that to accomplish this, we have to configure a few things.

The following are the steps to accomplish debugging X++ code in a batch server. The example is going to be using the SalesFormLetter class run method.

NOTE: Please use a Development or Test environment to try these steps.

1- Open the Client Configuration Utility and Click the Manage button. Choose Create New Configuration.

2- Give it a name. (I have chose Debug2713)

3- Set the server name, instance name and port (the default for the first instance of AX will be 2712. If you have more than one instance make sure you have the right port. In my case the AX second instance is 2713)

4- Go to the developer tab and check the both "Enable user breakpoints to debug in the business connector" and "Enable global breakpoints to debug code running in the business connector or client" check boxes.

5- Now open the Server Configuration File and Click the Manage button. Choose Create New Configuration. Give it a name (i.e. Debug)

6- Set the application file location and the alternate bin directory and the Application instance. In addition, check both the "Enable breakpoints to debug X++ code running on this server" and "Enable global breakpoints to debug X++ code running in batch jobs" check boxes.

7- Click the Database Connection tab and set both the server name and database name.

8- Open the AR module and go to Periodic > Clean Up > Sales update history clean up

9- Choose the Executed Clean Up option and a date and click OK.

10- Open the AOT, go to Classes and look for the SalesFormLetter class. Open the class and look for the Run method and place a breakpoint anywhere in the code.

12- Open the AX 2009 debugger

12 - Go to AR > Common Forms and open the Sales Order Details form. Choose an Open Order and click the Post button. Choose Packing Slip (i.e.)

13 - The SalesEditForm will open. Click the Batch button and set the batch.

14- After clicking the OK button you should see the following message

If you want to check the status of your batch you can go to Basic > Inquiries >Batch Job. Your scheduled job should be in there. Wait a few minutes and the debugger should open at the breakpoint you inserted before.

NOTE: Sometimes you will have to restart the AOS service when the debugger does not open and your job has already executed. In addition, you MUST have a batch group setup.

Take Care!

Monday, November 7, 2011

Get the active comapny in AX 2009 - curExt()

Use the curExt() function to get the active company in AX;

static void curExtExample(Args _arg)
str CompanyId;

CompanyId = curExt();

You would also use the following with the same results. However, the above is much more elegant.

static void curExtExample(Args _arg)
str CompanyId;

CompanyId = CompanyInfo::Find().DataAreaId;

Take Care!

Friday, November 4, 2011

Microsoft Dynamics AX 2012 White Paper: Selecting the Best Development Technology for Your Application Development Scenario

Microsoft Dynamics AX 2012 provides developers with new choices for programming models and developer technologies.

The following link discusses the following topics:

  • Development patterns in Microsoft Dynamics AX 2012
  • Programming models available in Microsoft Dynamics AX 2012
  • Changes to the core development framework in Microsoft Dynamics AX 2012
  • Selecting the appropriate programming model for your development patterns
  • The Microsoft Dynamics AX development technologies road map

Here is the link!

Wednesday, November 2, 2011

Indexes In Microsoft Dynamics AX

Today I would like to have a discussion about Indexes in AX. In my opinion, I think it is extremely important to create an architecture that will support the fast retrieving of records. In addition, there is no way we can provide a good service if we don’t provide a nice and easy to follow guide on indexes.  

So, basically indexes in databases are used to locate records and they are stored separately in the database. They contain a key that can be quickly located in the index, and this key will have a reference to a record.

For example, the let’s think on the SalesIdx index in the Sales Table. This table field index contains the SalesId of a Sales Order. Now, because the Sales order is unique and sequenced, an index will be used to quickly lookup the sales orders records through the reference.

Type of Indexes


A unique index is created based on a column; Microsoft Dynamics AX assures that no duplicate key values can occur in that same column. Also, when updating a column that contains a unique index will cause an error.


Non-unique indexes are created for performance reasons. In other words, they give a fast way of retrieving data. For example, (and here we can think on the example above about the SalesIdx) instead of doing a full-table search of all the records in a table, and non-unique index will help us narrow down this search to a reference.

In general, indexes use system space and must be updated every time system data is created, edited, or deleted. I have seen indexes slowing down the updating process. However in most cases the overall performance improvement when selecting records far outweighs the performance loss when updating.

Microsoft recommends that when creating an index to give it a name that reflects the names of the fields on a table plus the suffix Idx. (i.e. SalesIdx)

Creating Indexes

Creating indexes is not very difficult at all. You just want to make sure that the fields you want to create the index on exist in the table (I guess this is obvious, but you’ll be surprise with some of the question I have been asked over the years). Anyway, the indexes can be unique or non-unique, and are based on a single column or multiple columns that exist within the table.

  1. Locate a table in the AOT (This has to be a table in your Dev environment or some virtual machine AX)
  2. Right-click the Indexes node in the table and select New Index. A new index Index1 is created.
  3. Rename the index to the field name of the table/field you have chosen
  4. Drag the field you have chosen to the index created in the step above node.
  5. In the properties sheet for the created index node, set the property AllowDuplicates to No.

Just to make it more visually clear, please take a look at the following picture:

Take Care!

AX 2012 Extended Architecture

AX 2012 Extended Architecture
Besides the common (most simple) AX 2012 architecture, there are several other components of the Microsoft technology stack are used in a typical deployment.
The following is a list of the one that are most commonly deploy with implementations:
  1. Reports are delivered by SQL Reporting Services (SSRS). SSRS is a component included in SQL Server.
  2. Business Intelligence (BI) components such as Key Performance Indicators (KPI's) use Online Analytical Processing (OLAP) cubes which are delivered by SQL Analysis Services (SSAS). SSAS is a component included in SQL Server as well.
  3. The Enterprise Portal and Role Pages are hosted in SharePoint. There are two versions of SharePoint that can be used. Window SharePoint Foundation 2010 is a free download. Microsoft SharePoint Server 2010 is a product that can be purchased to provide extended collaboration and content management tools.
  4. Integration to other applications or to third party organizations might require integration solutions such as web services.
The following picture describes a high level extended architecture:

Take Care!

[Some of the iinformation in this article has been taken from a Microsoft Training Manuals]