AX 2012 Navigation Properties

It’s been a while since I’ve posted, but here’s a small little post about what I think is a cool feature in Ax 2012!

In AX2009, when you have a table that has a relation to another table and you want to use it in code, you have to provide a method that performs a select on the other table and returned the related record. ( fe : SalesTable.SalesLine() ) Well this is something cool in AX2012. Here’s how you can do it now.

On the main table you have the relationship. There you can use a new property called CreateNavigationPropertyMethods and set it to Yes.

Once you have done this, there will be a method on you table that returns the related record.


SQL Server : Change TempDB location

This is no rocket science but today I needed to move the tempDB to another disk. This is something I though could be done by changing the location path on the database properties in the files tab. Well, bummer, the location was not editable there. So how can we do this… ?
Running this query will solve this for you :
MODIFY FILE (NAME = tempdev, FILENAME = ‘F:MSSQLDatatempdb.mdf’);
MODIFY FILE (NAME = templog, FILENAME = ‘F:MSSQLDatatemplog.ldf’);

Performance in Dynamics Ax 2012

Today I attended what I think was the most interesting session of the conference for me. (There will be one about AIF today but I think this will not as interesting as what I learned about performance)

Basically what they did can be devided in these categories :

  • Scale up and scale out on AOSs and Clients
  • Utilize more SQL features
  • Application effeciency
  • World class diagnosis tools


The first part was about caching. They added a global cache but this time the cache is also available across sessions.
The cache also get syncronised between the AOS instances, but there is a short delay on this, so you never really can trust that the cache is identically on the other AOS Instances.

As to when the objects in the cache are cleared, there are two main triggers for deleting an object from the cache:

  • The limit of number of objects is reached (to be found in the SysGlobalConfiguration table on SQL Server
  • The developer deletes / overwrites the object in the cache


Before the trace parser was a tool to be installed additionally to Ax but now it is part of the system. There are a few ways in which you can use the trace parser:

  • By starting up the performance cockpit from the tools menu
  • By using it to code by starting and stopping trace and specifying a file to log to.

So this time it is actually much more stable and reliable to use. Actually now it is so easy that each developer should develop with the trace parser next to him at all times to keep performance in mind from the beginning.

Data Access : Ad Hoc mode

When your X++ query is getting too big, then use Ad Hoc mode. Here you would actually only select the fields you need.
Also, set the dynamics property on the query fields to false and set OnlyFetchActive to true on the FormDataSource

By selecting only the things you need, the kernel will not join all the tables in the table hierarchy but also the inherited tables where you need fields from.

SQL TempTable

In the AOT, you can now set the TableType on a table object to one of the following :

  • InMemory (The old in memory temp table)
  • Regular (Non temporary table)
  • TempDB (SQL Server tempDB table)


Here I can be brief (because the white paper about this is going to follow later on)

Basically the RunBase framework is now only there for backward compatibility! So now the new SysOperation framework will be used.
This is residing in the AOS also, but more on that when I have a clearer view on this.

So this is what I could capture from the session. Probably missed a lot of other stuff too but for that, we will have the video’s J

Dynamics Ax 2012 Technical conference : Day 1 : Part 1

This articles will be brief, because I don’t have much time between the sessions J

Yesterdag was the first day of the Dynamics Technical conference and following sessions were attended by me:

  • Programming model improvements Part 1 of 2
  • Programming model improvements Part 2 of 2
  • Developing in .NET managed code and X++ Enhancements
  • Solving the element ID problem

Programming model improvements Part 1 of 2

From this session, I remember the following additional features:

  • Table inheritance is added. So now you can have abstract tables which are then inherited by child tables.
    The unit of work pattern also comes into play here as there will be issues to address to manage transactions and code dealing with one ‘virtual record’ which may consist of multiple child tables. (Vehicle table with child tables bycicle, car, truck, …)
  • Next to normal X++ temporary tables, there is now also support for temporary tables in SQL Server
  • Date effective tables have been added. This means you can actualy filter records based on an ‘effective as of date’
  • Eventing has been added so now you can actually subscribe methods to events on other classes. Also, this is implemented by drag and drop so it is actually user friendly to do this.
  • The normal batch framework has been ‘adjusted / replaced’ with the SysOperation framework
  • The tree of linked tables are then linked by RecId, but you can actually have a key with fields specified in a field group to be used in the design when showing on what the linked was based
  • Tables have full text indes support now : This means they can be optimized for searches on text fields to look for certain words in the body.

Historical data pattern

This one is actually cool. Let’s say you have a historical table to contain a history of sales. Then you can set properties on the SalesTable datasource and the kernel will keep the history for you. So when you change values on the sales order for example, the kernel will create / update records in the historical data table.

Query ranges vs Query filters

When using joins (outer joins) the query ranges can produce incorrect outcomes. But now query filters are used to fix that. Instead of using the QueryRange object on the query, you can now also use QueryFilter objects and they are more optimized for SQL Server.

The other sessions will be describes in following posts as there is new session beginning right now J

IDMF Post Installation Issue : ODBC Connection

After the installation of the IDMF there are some post installation steps to do. One of them is to populate the IDMF Management database with data from the Cross Reference.

To do this, some job has to be run on the production database that makes connection to the IDMF database by ODBC. When I tried to do this I get the error that the connection failed. Therefor I have made a little change to the classes responsible for the population.

The DMTPopulateManagementDBcreateConnection method is altered to work with a DSN (for some reason it did not work for me if not using a DSN) (And please don’t mind the hard coded name J)

For this to work, we need to create a system DSN on Windows to point to the SQL Server database. So we create one:

But there is one issue here: On a 64-bit 2008 Server, the dynamics client will not find the 64-bit DSN created, so we have to start the 32 bit version of the ODBC Tool.

When the 32 bit DSN is created, it worked for me.

AIF: Service actions lost after recreating service

When you delete service objects (classes, macros, service node…) and recreate the service you may have run into the issue that none of the service operations were visible.
Here’s how I solved it today when having the same issue. (We had to remove everything or else the problem was not solved)  

The problem is that the actions are not gone, but they were linked incorrectly. The AIFAction table contains the operations and also contains the classId of the class where the methods to handle the actions are.  


Well as the service objects were deleted and afterwards recreated, the class ID of the service class had been altered. Due to this changed ID, none of the operations were visible on the service.  

To fix this, just delete the current records in the AIFAction table for the corresponding service and then we can recreate the actions by calling the AIFServiceGenerationManager class,
method RegisterService.  


Then we can see the operations again in the services form.  

Decisions Dynamics Ax Virtual Conference

This afternoon the virtual conference will take place at 09:00 am EST (3 pm ET).

Decisions technical conference

The session content can be found here but I’m particularly interested in the Performance session (presented by Dick Wenning) and the Batch framework session (presented by Robert Boone).

Please not that registering can still be done and is completely free of charge !
So see you guys at the virtual conference then ! (That is, if I can get to log in to the conference since I haven’t found the login link yet 😉 )

AIF : Enable net.tcp binding on WCF service

Today I wanted to check out what the impact of changing the binding method to net.tcp instead of wsHttpBinding was. But to be able to use net.tcp as a binding, some things need to be done.

IIS Setup

The first thing to do is making sure everything is in place on the IIS 7 side.
For being enabled as binding method, make sure the following feature is installed.

By installing this, you can add net.tcp bindings in IIS. So right now we can start by going to the IIS manager and add net.tcp as a binding method on the Dynamics Ax AIF Application.

After adding the site binding, enable the net.tcp binding as protocol on the Application

Dynamics Ax AIF Webservice setup

Once the IIS is ready to pass net.tcp requests, we can configure the Dynamics Ax Web Service to work with net.tcp binding.

Inside Dynamics Ax, go to Basic à Setup à Application Integration Framework à Services and click the configure button. Now the configuration editor will start. Here you can select the service you want to alter and change the binding method to net.tcp. You also have to specify the address here. In this case it is: net.tcp://hostname:808/DynamicsAX50AIFServices/nvmpconfigtableservice.svc

Once you have done this, you can go ahead and regenerate the service artifacts and refresh the services on the calling applications.

Event Handling in X++

When you are writing code in C# you can create events and define delegate methods that will be called when the event is triggered. Unfortunately, this is not implemented in the X++ language.

I have read some nice posts about how eventing is implemented in .NET and about the design patterns used (observer, …) and decided to build this myself.

The method I used is using the observer pattern and lets you subscribe to an eventhandler object that can be defined on a class you want to monitor. It is actually quite simple, but can come in handy when available.

Note : Don’t mind the HEL prefix, this is just a prefix used for some tools here. And also, some objects can be extended with additional functionality to contain more information, …

First I created an HELEventHandler class which contains a map with registered listener objects. The methods attachListener and removeListener can be used to register / deregister an object method to listen for the event. The validateListener performs some checks to see if the callback method has the right structure. The fireEvent method is responsible to notify all the listeners of the event triggered.

The HELEventArguments class is created just to pass it when the event is fired. For now, this is an empty shell, but can be extended / adjusted to contain extra information on the fired event.

Now let’s see how we can put this to work. First we start by create a class for testing: HELTestClassEvent. We have a name member here and an eventhandler member.

class HELTestClassEvent
    Name mName;
    HELIEventHandler mNameChangedEventHandler;

The eventhandler is made public by adding a parameter method.

public HELIEventHandler parmNameChangedEventHandler(HELIEventHandler _nameChangedEventHandler = mNameChangedEventHandler)
    mNameChangedEventHandler = _nameChangedEventHandler;
    return mNameChangedEventHandler;

Now let’s say we want an event that is triggered when the name changes. Then we would like to add a method that can be called to notify that the name has changed.

private void onNameChanged(Object _sender, HELEventArguments _arguments)
        this.parmNameChangedEventHandler().fireEvent(_sender, _arguments);

And this will be called like this :

void run()
    mName = "Kenny";

    this.onNameChanged(this, new HELEventArguments());

    info("I did my work");

For now, we have everything we need to let an object notify others that an event has happened. Now we will take a look at how we can register other objects to listen to this event. Let’s create an extra class that will be notified. There, we will first need to create a method that will do the actual work when the event is fired.

public void HELTestClassEvent_OnNameChanged(Object _sender, HELEventArguments _eventArgs)
    info("Who changed the name ?!");

And last but not least we actually attach this method to the event by doing this:

void run()
    HELTestClassEvent test = HELTestClassEvent::construct();

    // We want to attach a method of this class to the event that the name is changed in the HELTestClassEvent object
    test.parmNameChangedEventHandler().attachListener(this, methodStr(HELTestClassEventCalledBack, HELTestClassEvent_OnNameChanged));

    // Run the HELTestClassEvent object;

The source can be found here