AX 2012 R2 - Installing new databases from setup

maqk® by MolviDSLR Khan | 7:43 PM

Their can be scenarios when you want multiple databases on the same service. For example having a separated testing environment, development environment, staging and production.

I mentioned one such scenario in one of my previous posts in which I installed the new databases only to see the face of another error :) The 110 error code. 

The thing is, when you install new databases from the AX 2012 R2 setup, it does install new databases quite successfully. However, it misses two critical stored procedures on the database, the CREATESERVERSESSIONS and CREATEUSERSESSIONS

You can get these stored procedures from any dynamics ax 2012 r2 database and an apply on to your new database to fix the error.

Dynamics AX 2012 R2 Fatal SQL condition during login

maqk® by MolviDSLR Khan | 6:26 PM

An interesting yet dangerous thing happened in my AX life today. Actually in one of our environments, we had previously upgraded to CU6. Now somehow the AX server VPC got restored to the earliest snapshot available forcing us to install a new fresh AOS service instance. The service was installed in no time but only to give the following error at each start and failing each time.

A peep into the event log yield the following information:

Object Server 01: Fatal SQL condition during login. Error message: "The internal time zone version number stored in the database is higher than the version supported by the Kernel (4/2). Use a newer Microsoft Dynamics AX kernel."
I have the following roadmap for the resolution now :)

  1. Install clean databases with new names
  2. Connect installed service to new database and start AOS service
  3. Compile application code and sync database
  4. Upgrade to CU6
  5. Connect AOS service with existing CU6 compatible databases
  6. Resume from whatever we left
To my retro suprise, the service failed to start with error code 110 after configuring to connect with new databases. This matter was resolved menrioned in another blog.

Now resuming from point 3 :) 

DAX 2012 R2 CU6 SYP Labels issue fix

maqk® by MolviDSLR Khan | 12:26 PM

I recently upgraded my local environment from Dynamic Ax 2012 R2 (Flat: build no# to CU6 (6.2.1000.1437 - 2012 R2 Cumulative Update 6 (CU6)). The process was seamless however one issue arrived. The lable files. A lot of labels (in various mnodules including GL etc) started appearing as just flat label IDs 

Info log after CU6 upgrade

I found the solution in one of Ing. Karel Fischl's msdn blog: Missing SYP labels after upgrading to AX2012 R2 CU6 with just a minor adjustment, the two types of files to be removed from the location: are 

  • ALC files (Label description)
  • ALD files (Label data)
And thats it, worked 100% on my production :)

Dynamics AX 2012 - Workflow not working properly

maqk® by MolviDSLR Khan | 3:56 PM

While doing some customizations, I needed to use the purchase requisition workflow. However after submitting the purchase requisition, the workflow wont proceed and no work items would create.

Batch job and Batch groups

Workflow is dependent on batch groups. Perhaps all tasks appearing under the 'Periodic' heading are. The development environment I was working on had an empty named batch group. But the problem is not with a no name or empty name thing. It is the details the batch group carries, if it carries any :)

A Batch Group represents a Batch Server (AOS Server)

Its all about distributing workload and responsibility, for load balancing. A batch group posses no significance if it has no AOS servers associated to it. See the picture below;
System Administration > Setup > Batch Group

Hence if the workflow activities and tasks generated are being dependant on an empty batch, such activities wont occur / complete.

The Story

In my case, the empty batch group was really empty (rotfl) and I dont know for what reason it was like that. What really happened was that first I went to sys Adm > Inquiries > Batch Jobs. There I tried to tweak with multiple waiting, error status jobs. I came to find that only the With Hold status jobs are modifiable. Once that was known, I started putting the jobs on this status and doing things with them. There I saw no name appearing in the batch. This also raised the question if this empty batch associated has issues with it. Later I went to see no server is associated with the group. I associated the default and only AOS server  on the VM to the group and there you go :) Happy workflowing

Some useful links for your reference are attached below;


DAX - Some useful links regarding debugging

maqk® by MolviDSLR Khan | 3:41 PM

This one is a short blog post to index a few hands on studd when working with grids

  • To enable multiple row selection on the grid, set the property 'MultiSelect' to Yes
  • To display a checkbox along with each row to remember each row selection, set the property 'ShowRowLabels' to Yes
  • Code to get the currently selected rows: tableName_ds.recordsMarked().lastIndex()

For quite some time, I was looking for this answer ? What benefit in the world does multiple models give ? I just could not figure it out from the basic definitions available at most of the places

model is a set of elements in a given layer. Each layer consists of one or more models. Each layer contains one system-generated model that is specific to that layer. Every element in a layer belongs to only one model. In other words, no element can belong to two models in the same layer, and every element must belong to a model.
There we some questions that kept arising all the time

  • Is the end user suppose to switch in between the available models ?
  • If two or more models can be operational, what in the world is is the significance of the current model
And so many more, it was all too frustrated. To my surprise, most of the available developers and consultants were even not able to clear my concept of the purpose of multiple models side by side. To my luck, I came across a convergence video about models and metadata architecture. There, the presenter cleared it all away. 

Actually models are providing a way to export customizations (from say development or staging environment ), import them in another environment (production) without disturbing as many models already installed from n numbers of ISVs and vendors. 

Let me explain the concept with an example. Lets suppose you being an end user have a customization deployed in your production environment from vendor A, on the form, say.... Vendor List Page. And those customizations has additional menu buttons in the Action Pane. Now you bought another solution which has other customizations on the same form. Now you already have the Vendor form customized in, say VAR layer and the new vendor is also developing customizations in VAR layer ? So how would the two different versions co exist now ? How would the same element on the same layer have 2 different versions with end user expecting to get the new customizations without disturbing the already deployed customizations. This is where models come to play :) 

Since each layer can have multiple models, or slices if you ask the framework developers, each vendor can now produce their own model, install at the same layer, and both co exists meaning 2 different model customizations will be available at run time for the end user. This has questioned both of my questions actually since the current model is for developers and not for end users and that all models on respective layers render on runtime shadowing the layers  underneath.

Dynamics AX 2012 Workspace titile and the Info Class

maqk® by MolviDSLR Khan | 10:30 AM

The Info Class has a very special place among the classes provided by the AOT to work with. It is a framework class that mainly deals with the information, warning, or error messages shown by the AX client, Infolog in other words. All the infolog messages displayed on the AX client are constructed using the Info class.

However the InfoLog also has methods and attributes to handle the Dynamics AX workspace window. This post will describe a few cases where the Info class can be used besides creating and displaying an infolog. The most obvious one being the target of this post: Show the active configuration in the main window title bar.

As we discussed in a post earlier, we needed to have the same client connected to various server configurations. And we created multiple shortcuts of the client, and using command line parameters, appended the regConfig command with each shortcut's Target property and their you go, same client with two different shortcuts connecting with two different server configurations. 

However, since the client is the same, we needed to have some text value or string representing each client's active configuration so that we can comfortably identify which instance we are currently working on. This can help a lot while working on both the environments side by side. Here comes the Info class to play. 

We need to append the active configuration name with the window title. And we all know their should be no rocket science involved in it and their is none.

A child's look at the Info Class :)

Dynamics AX 2012 > AOT > Classes > Info: A child's look :) 

We see that the class contains a few methods that are triggered on the respective events. We are mainly interested in the workspaceWindowCreated method.

This method is executed when the workspace window is created. And we have an integer _hWnd handler parameter through which, we can refer to the created window. All we need to do is to add the following lines to the code;

void workspaceWindowCreated(int _hWnd)

    // Put workspace window specific initialization here.
            WinAPI::getWindowText(_hWnd) + " - " + 
            xInfo::configuration() + "");


A few interesting links about the Info class that I could google out are provided;

This error appeared in our environment when we started importing configuration files for bulk deployment. You can export a working configuration so that the same can be distributed to n number of clients. 

Exporting the working configuration from one environment and re-importing in another gave this error on one of the clients.

Microsoft Dynamics AX Error
An invalid directory structure for Microsoft Dynamics AX was detected. The subdirectory C:\Program Files (x86)\Microsoft Dynamics AX\60\\Client\bin does not exist.

To my surprise, the path mentioned in the error, "\Program Files (x86)\Microsoft Dynamics AX\60\\Client\bin" never existed at the client I was working on. Why would this false path generate from this client ? Left curious at my place, I googled the same and came accross the post: 

As rightly mentioned in the post, you need to fix the registry. These configurations are actually stored in the registry. The config executables modify the registry entries actually. And from there, the client or the server reads and loads accordingly. A different client directory path in the original configuration (exported from) will propagate in all clients with imported configurations. At this error, check the registry at the path:
HKEY_CURRENT_USER\Software\Microsoft\Dynamics\5.0\Configuration\Original (installed configuration)
 and look for the directory, bindir and datadir values.

What actually happened is that the client initially configured [and configurations exported from there] had its client installed in the \Program Files (x86) folder. However a few other clients were in the \Program Files folder. Now exported configurations are totally dependent on the original system paths and directories. Hence the initial system path propagated and didn't get checked in the middle. 

Perhaps we can have system variables representing the AX client path and AX server path and other significant locations so that such issues are mitigated.
A scenario at our end required to have the same client able to connect to multiple AOS server instances, say DEVELOPMENT, TEST and PRODUCTION environments. One way is to have multiple client configurations, and toggle them to the desired server configuration when needed. See the image below;

Dynamics AX Client configuration utility

However for more ease of use and friendly behaviour, we can have a single client with multiple shortcuts each toggling the client configurations on run time based on command line parameters :) But to successfully do this, we obviously need to know the command parameters we can attach to the AX client executable [AX32.exe]. So here we go;

Client configuration commands [AX 2012]


Now with the information from the above link, we come to know that regConfig is the parameter we can provide with the AX32.exe to mention the client configuration name the client will run accordingly. A sample command is compiled as follows;

ax32.exe -regConfig=ConfigName

You can test the above command with correct configuration names from the Run command box [Windows+R] and can play with it too :)
Try to provide an incorrect configuration name and see what happens. Try giving a wrong command and notice the behaviour.

Coming back to the topic, what we did was to have two different shortcuts, each with its own command line parameters
  • Client 1 - "AX32.exe - regConfig=YourFirstAOSClientConfig"  
  • Client 2 - "AX32.exe - regConfig=YourSecondAOSClientConfig"  

See the image below;

Now both the shortcuts are pointing to the same single AX32.exe but with different values in the parameter '-regConfig' thus directing the client to connect to a different client configuration from the default one. Now these configurations can be a copy of each other or associated to the same server with different databases or entirely different AOS servers, this is entirely up to you how you need it :)

Have you ever encountered such an error while doing a routine database backup;

RESTORE failed for Server
Restore failed for Server 'SERVERNAME'.  (Microsoft.SqlServer.SmoExtended) ADDITIONAL INFORMATION: System.Data.SqlClient.SqlError: RESTORE cannot process database 'YourDataBaseName' because it is in use by this session. It is recommended that the master database be used when performing this operation. (Microsoft.SqlServer.Smo)
The first thing to come in mind perhaps would be to ... end all active connections to the database. Some of us would straight go to the detach database option to see the active connections. What ? 'Ctrl + Alt + A' you said for activity monitor to end the processes? Yes of course but the above error won't go even if you restart the whole SQL Server service. Why ? What could be wrong ?

The mystery in our case was the fact that for some reasons unknown, the default database was changed from master to the Dynamics AX transaction database. Now when ever you try to restore on a database that is the default database of the active user, this message would appear.


Make sure the database you are restoring is not your user's default database :)

FRx 6.7 installation and configuration on Dynamics AX 2009

FRx is a very good tool for financial reporting. Now obsolete perhaps, since MR ->Management Reporter for DAX 2009 and above has taken its place. A casual installation checklist is as follows;
  • Install FRx 6.7
  • Run scripts in the correct order [file names suggestible]
  • Install the latest service packs [see the links section below]
  • Import the 2 jobs
    • frx.xpo [gives AOT -> Jobs -> DumpVirtualCompanyMap]
    • frxmetadata.xpo [gives  AOT -> Jobs -> FRxMetaData]
  • Execute the jobs
    • AOT -> Jobs -> DumpVirtualCompanyMap - save the xml file
    • AOT -> Jobs -> FRxMetaData - save the xml file
  • Run the Financial Dimension wizard
    • In the FRx installation directory, run the file named 'Microsoft.FRx.Integrations.DimensionWizard.
  • Create a new system DNS and connec it to your AX db [you can set both Windows Auth or SQL Server Auth]
  • Start FRx report designer
  • Provide keys for your company and register the software. Without this step, FRx wont work fully.
  • Set Company information - Provide the newly created system DSN in the 'Data Source Name' field.
  • Set the company as default
NOTE: The order of the checklist might not be absolutely perfect, however this order would surely end you with a working FRx application :)

Common issues and resolutions

In the last 2 points above, you may get some errors while setting your company as default or just selecting your company to start working. You may get one of the following errors;
  • Direct Link error: Login Failed. Make sure the Login ID and password are correct and verify the settings on the system specific information page in company. FRX32.OFSIMain.CheckOFSIConnection 8900: A Direct Link error has occurred attempting to connect to the DB for this company. [src: FRx DirectLink error]
  • The specified company could not be found: FRX32.OFSIMain.CheckOFSI Connection 8900: The specified company could not be found. 
Both of these issues alternatively have been messing my FRx experience for quite some time. And then I realised to go for the SQL Profiler in order to dig deep. This revealed very critical information that was quite helpful in resolving the issues. 

Their are two key tables identified in the resolution of these issues;

  • frl_sys_options: Holds each company configured in Dynamics AX
  • frl_entity: Holsd the company specific information provided from FRx client 
These are created and filled by the scripts that are ran during installation. Both of these tables are queried when saving company information at FRx or setting the company as default. Setting your company as default is necessary for FRx to work on your company. 

If the scripts are not executed at all, or missed due to negligence or any other reason, the table would either not be created or not filled. In both cases, this would cause errors. This table should have a record for each company configured in AX. The dimension wizard is also dependant on this table and would not load entities [companies] correctly. See the image below;

Financial Dimension wizard
FRx installation: Dimension wizard not showing any company due to data missing in the system table

Similarly an empty 'frl_sys_options' table would give the DirectLink error. DirectLink is also given for other issues like wrong password etc. Verify the scripts are perfectly executed. If not, execute them in the correct order. 

The other table, 'frl_entity' holds the company data that you set from the FRx configuration window. However if while setting the company information and system specific information, you do not provide the dimension structure field, it would cause the Specified company could not be found error.
FRx - System specific information
FRx -> System specific Information. Note the Dimension structure field is mandatory hence bordered.

From the investigation, I came to know that each company is queried based on its dimension structure. So consider this field as MANDATORY and DO provide this field while setting the company information.

Where is this Dimension Structure configured in AX ? or What to write in the Dimension structure field?

This is not configured by you or anyone else from the AX client. The scripts fill the table with Company code [DAT for instance] and the string part '-Default'. So you can provide 'YourCompanyCode-Default' [DAT-Default for instance] or you can simple query the table to see what is it expecting you to write.

Unfortunately I could not found any detailed investigative blog when I was facing these issues and I was misdirected a lot towards issues at the ODBC datasource and authentication level. Now after these investigations, FRx installation remains no issue for me at all. Links are at your service below :)

Some useful FRx 6.7 Links

Country Region codes in Dynamics AX 2012 R2

maqk® by MolviDSLR Khan | 11:51 AM

The hierarchy of License Codes and Configuration Keys have one more far related cousin to mention here, The Country Region Code. I have just figured out this relation due to the nature of both being the same, Enable / Disable functionality. 

License Codes toggle features. Configuration Keys toggle various functionalities inside the boundaries of those features. Country / Region Codes toggle what? The answer to this is nothing from out of the box but neither is my topic to discuss here. 

Country / Region Codes can perhaps toggle both features and functionalities inside, but based on what ? is my topic. Again its simple so lets keep it simple. A picture worth a million words, or sometimes even more than that :)

Country / Region Codes - Applicable at both Table and Field levels

The question is how do they apply in AX 2012 ? Previously to toggle country region specific functionality, country region configuration keys were provided. In R2, those keys are still there, but they don't toggle any thing, because regional functionality toggle is now seperately handled at country region codes. This CountryRegionCode attribute is applicable on tables, fields, EDTs, BaseEnums, Forms (fields and controls), Menus, Menu Items etc

From the above image, it is clear that we have a couple of country region code specific fields to apply a particular region code to an item. That means each item can have a list of country / region code on which it will be available. Now how to apply a country / region code to the running system ?  And which country / region code is currently active ? The answer to these very basic questions is the country location of the primary address of the currently active company. Let my quote Microsoft here :)

Features that are specific to a country or region are enabled and disabled based on the primary address of the legal entity. For more information, see Create or modify a legal entity. [src]
The country/region that you select for the primary address of the legal entity controls the country/region-specific features that are available for the legal entity. [src] 

Apart from all this, one more thing that you should know is that security keys are obsolete in AX 2012 R2. Click here for more.


Applying Country Specific Functionality [AX 2012]

Today I woke up [spawned at office ;) ] only to find this

Dynamics AX 2012 R2 - Server terminated unexpectedly with 90 exitcode
Dynamics AX 2012 R2 - Server terminated unexpectedly with 90 exitcode

The AOS server service was down with the above error. This was not a great start for the day and ultimately I had to put myself in the investigation gear. Peeping in to the event log gave this;

Windows event log - Server terminated unexpectedly with 90 exitcode

Google returned irrelevant things so I just went to the AX Server configuration to find this

Dynamics AX 2012 R2 - Server Configuration (Note no database server provided)

Providing the database server and restarting the service resolved the issue. Now what remains is the fact that who peeped into my office yesterday (while i was at client) and did all the mess ;)

Financial dimensions is an advanced topic in Dynamics AX 2012. There are various aspects to learn this topic. My original requirement was to setup a new financial dimension and define some data for it. Adding a new financial dimension is as easy as pie. You can create a new financial dimension by following the following path:
GL > Setup > Financial Dimensions > Financial Dimensions

Due to the extra ordinary flexibility built in by Microsoft in Dynamics AX 2012, you can create as much as financial dimensions (aka ledger dimensions) as you wish. However as per the best practices and common usages, pretty fair amount of such dimension types are built in the system. As you can see from the image below, there is an option of 'custom dimension' available with the other pre defined dimension types.
Fig a. Creating new dimension

So adding a financial dimension is really as easy as APIE. What was a surprise for me (due to my own lack of knowledge :D, pretty dumb huh ) was the method of defining data for these new dimensions.

Normally one would expect to have a dedicated form for adding data for a dimension. And this is what the case really is if you see the highlighted area in the following image.
Fig b. Financial dimension values

The surprise is that when the button "Financial dimension values" is clicked to open the concerned form, the new button is disabled. And it remains disabled for each dimension that I add. The question arising in my mind "Where to add data for this dimension ? Where to define the expense purposes ? where to define data for each of these system defined dimensions"

And this is where Google is very handy. See in my scenario, I had to define expense purposes (cause that will enable me import an account structure and add some gen journals from code), so I googled "dynamics ax 2012 new expense purpose" and the first post actually resolved my query :D

Each dimension's value is based on the selection you make in the dimension setup form ( see fig a above ). These are all existing modules of the system and the value forms and menu items already exist. To add new values for a dimension based on these system modules, you have to browse those relevant forms, fill the data there and expect the values to reflect here :)

Take expense purposes for example. If you have added an expense purposes financial dimension into your account structure, you can define the data for this dimension from Travel and expense > Setup > Optional Setup > Expense purposes

I will share a few important ones for you as follows;

  • Fixed assets: Fixed assets > Setup > Fixed asset groups
  • ProjectContract: Project management and accounting > Projects > Project contract

The 2nd question arises ? Does that Financial dimension values > New button enables ever or is it just dropped there mistakenly. The answer is "Custom Dimension". Yes its the custom dimension whose data is definable here. See the image below please;

Fig c. New financial dimension value

A few more related things
Chart of accounts is one thing, and account structure is another.
Chart of accounts
It is the collection of all the main accounts that we create. Every single account exists in the chart of accounts (table: MainAccount)

Account Structure
Account structure is the combination of main accounts with the defined financial dimensions. This means what financial dimensions will used along with accounts generally for transactions. Consider the following image.
Fig d. Define accounting structure 

As you can see, the fully qualified account structure is composed of the main account followed by department > cost center > expense purpose. And for the explanation of extending the account structure, the  "Add segment" button functionality is shown in which you can select available dimensions to further enhance and granulate the main accounts.

Though it has been very boring and time consuming for me in the beginning, yet it ended quite fruitful to me in the end :)

Without further delay, one of the most common and basic task when implementing an enterprise system is to import the legacy system setup data into the new system. The objective of this post is to share all the basic tools and scenarios you will need to import / export data.

This post will specifically provide guidance on importing records from external sources like excel file into Microsoft Dynamics AX 2012. But first of all, lets see how much variety has Microsoft provided in the regards of data import export and migration between the AX and other system;

http://technet.microsoft.com/en-us/library/aa548629.aspx : A worthy resource to begin with. Read the small article and get a good basic idea of all the tools provided by Microsoft and their purposes.

Secondly lets get hands on importing a few records in some setup table of AX, say MainAccount (chart of accounts table). By the way you can import data into any AX table

Quoting from the above mentioned post:
Microsoft Excel Add-in: Excel import is a tool that can be used for data in an Excel format, or in a comma-separated list. You can use built-in or custom templates to help users import data. Use this tool in the following situations:
  • Minimal data cleansing by end users is required.
  • You are handling low to medium data volumes (< 10,000 records).
  • You are working with simple data structures that can easily be flattened.
  • No business logic is required outside an existing document service.
Now since this is quite a handy and straight forward tool powerful enough to handle around 10000 records, it would be the pick for us for basic setup data import. Hence we will use excel add in for setup data imports.

For installation and configuration with AX, see these posts:

The usage as far as import is concerned is fantastically straight forward. And if the tool is rightly configured (i was lucky to got it configured already at my place :) ),  its as easy as PIE literally. All you have to do is to follow the following straight points:
  • Create a new document.
  • Go to Dynamics AX tab
  • Scroll click the Action Pane > Design > Add Data command menu button
  • Click Add tables menu item
  • Select the desired table (all tables are provided, in our example we will select the MainAccount table)
  • This will enhance the excel UI with a Field chooser left bar (showing all the fields) and a few mandatory fields (typically the PK and FKs) dropped over the worksheet.
  • Select at least all the mandatory fields required to save a valid record in the selected table. In our example, we will drop the following fields;
    • Chart of accounts
    • Main account
    • Name
    • Main account type
    • Reference ID
  • To load data from the table: Close the field bar (which should enable the publish button) and hit Action Pane > Update > Publish
  • Start creating records by simple typing and tabbing to next fields and to next records.
  • To save your work back in AX, hit the publish button and you are done
  • Publish button disabled: Close the field bar on the left. You should close this bar as soon as you are done with choosing the fields. Closing the field bar may result in wiping all the newly created records. Make sure you close it as soon as you are done adding the fields
There are quite a lot worthier posts on the internet on the topic. The goal of this post is to bring under 1 umbrella all the basic steps required to start importing data and share / reuse existing worthy resources over the internet on this topic. The most worthy of them I found are the data import series blogs here: https://community.dynamics.com/ax/b/ax2012exceldataimport/default.aspx

Enjoy importing data into Dynamics AX like APIE :)
In continuation to a post written several months ago [http://dotnetxperience.blogspot.com/2012/07/number-sequence-framework-in-dynamics.html ], I thought to make a class diagram in order to show all the related objects required for successfully implementing the number sequence framework. The original motive was to write one COMPLETE post depicting all aspects fo the framework however i am not satisfied from my effort. I will improve it for all of you and for myself as well.

At the moment, I am sharing the class diagram. It s not the best of them, but for sure it will assists all of us in better understanding of the framework.

Some tips when using Expressions in X++ Dynamics AX

maqk® by MolviDSLR Khan | 2:04 AM

Expressions come to rescue when you need to code complex joins and constraints in your queries. I always have trouble setting my larger expressions with quotations and parenthesis  It always looked perfect but they always gave error. This was due to no proper Expression specification under my observation untill I found the following (The excerpt is taken from a book on AX: Microsoft Dynamics AX 2012 Development Cookbook )

  • The expression must be enclosed within single quotes.
  • Inside, the whole expression has to be enclosed in parenthesis.
  • Each sub expression must be enclosed in parentheses too.
  • String values have to be enclosed within double quotes.
  • For enumerations use their numeric values.
  • For value formatting use various Dynamics AX functions, such as queryValue(), Date2StrXpp(), or methods from the SysQuery class.