Category Archives: Dynamics AX 2012

Cannot add or remove static keyword for this method

A while ago while delivering code for a customer (in Microsoft Dynamics AX 2012) I ran in to this problem while compiling with axbuild.exe (but not while compiling in the aot).
I haven’t been able to reproduce this error after fixing the problem, but from what I read there might be several ways to reproduce it.

So, how did I fix this?
First things first.. What does the error message mean and why does it only appear while using axbuild.exe?
Since last compilation of the object the static keyword on the method you are trying to compile has been removed or added.
When the static keyword is being added/removed you are note only changing the plain text code of the method, but also the type of the object.

The type of an aot object is stored in the model database in the table “ModelElement”.
As you can see there is a field named “ElementType”.
2016-05-30 16-52-35

And here is Microsoft’s list of types.

The problem when you get this error message is that the element type is not in sync with the plain text code.
For example: Your method is saved as a static method, but in the “ModelElement” table the element type is still 12 (TableInstanceMethod) where it should be 22 (TableStaticMethod).
For some reason the compiler in the aot does not validate this, but the axbuild.exe compiler does.

Here is a comparison I did between the source and destination environment during my installation of code.

Changing this directly in sql with “Sql Server Management Studio” will do the trick.

Sales line number not unique

There are cases in all current versions of Microsoft Dynamics AX where the line number on sales order lines is not incrementally assigned and can therefore be assigned in duplicates.

For the purpose of the post i have added the field “Linenum” to the grid in the sales order form.

As you can see below the line numbers are assigned incrementally when creating order lines in an ordinary fashion. (one by one).
2016-05-27 10-35-15

Some sellers might decide to add a few empty sales lines to the order before picking the item number like this.
2016-05-27 10-44-41

At this point the line number still looks normal.
But lets see what happens when when we start picking values for these lines and saving them.
2016-05-27 10-48-05

In this example i start by assigning an item number for the last row and then for the first row.
As soon as the item number is assigned and i leave the field, the line number is changed to 3.

The first thing you might ask yourself is: “Why the heck would you create order lines this way?”
That i can’t answer, but i know for sure that it’s not totally uncommon.

If sales line number are not unique you might run in to problems with some customizations that uses the line number to identify the sales line.

Our solution for this is to enforce a more “normal” behavior by adding a piece of code that deletes all cached sales lines every time a sales line is saved.

Simply add this method to the data source “SalesLine” in the form “SalesTable”.

private void HandleMultipleCacheLines()
    SalesLine   salesLineLineNum;
    salesLineLineNum = salesLine_ds.getFirst();
    while (salesLineLineNum.SalesId)
        if (!salesLineLineNum.RecId)
        salesLineLineNum = salesLine_ds.getNext();

And call the new method from within the method “write” on the data source “SalesLine”.
Put the call right below “super();”.

Please let me know if you have a another solution.

DMF – DMF Service is unavailable

I got this message in the Beta 2 version of the Data Migration Framework in Dynamics AX 2012.

This link is an important piece of information that you will need to understand some of the errors you get while trying to set up some of the new functionality in BETA 2, such as ODBC connection as a source data format.

I got this message when I was trying to validate the connection string to an ODBC database. The reason for this was that the original installation had failed because of some unknown reason.

DMF Service is unavailable

It´s important to know that we, in this case, have the installation of the server integration services on the same server as the AOS.

In Beta 1 the installation resulted in one new folder under program files, in Beta 2 there should be three folders.

1. Microsoft Dynamics AX 2012 Data Migration Framework Server Components(Beta)
2. Microsoft Dynamics AX 2012 Data Migration Framework Client Components(Beta)
3. Microsoft Dynamics AX 2012 Data Migration Framework Service (Beta)

In our case the Service folder and it´s content was missing. Knowing this, the error message I got started to make a lot more sense.

This is how you test if your service is up and running. Log in to your AOS server and open a browser, then enter this URL in your web browser:


Of course you have to change the “DMF-Service-ComputerName” part to your server name first.

When we tried this, the service was not up and running. What we did was to turn of the AOS service and then run the installation process again for the service part of the DMF installation. After it was finished our “Microsoft Dynamics AX 2012 Data Migration Framework Service (Beta)” folder was where is should have been all along, under Program files.

We then started the AOS service and tried again. This time we could both access the service using the URL in a browser and validate the connection string to the database on the odbc source data format.

On to the next challenge.

DMF – Error occured while doing bulkcopy from temp table to entity table

This is a generic error message you get in data migration framework from time to time.

Error occured while doing bulkcopy from temp table to entity table

I have found that the reason for this could one of many. This is the ones I have encountered.

Continue reading DMF – Error occured while doing bulkcopy from temp table to entity table

DMF – Cannot create a record in Product number (EcoResProductIdentifier)

When working with the new Data migration framework module in Dynamics AX 2012 you will encounter a lot of problems and strange errors. One I recently encountered is this error message.

“Cannot create a record in Product number (EcoResProductIdentifier). The record already exists”

Continue reading DMF – Cannot create a record in Product number (EcoResProductIdentifier)