How to Read a Trace log etl file in Dynamics AX 2012

In my previous post I showed how to capture a Trace of Payment Term creation that results in an etl file being generated. To read that trace we need to have Microsoft Dynamics AX Trace Parser installed. You do not need to be on the same machine that you took the trace on, you only need the ETL file. In the below video I quickly go over how to read a Trace file and the different options Trace parser provides. To see how to capture a trace read: How to capture a Trace log of any process in Dynamics AX 2012


How to read data from a production instance in D365 #Dyn365FO

Recently I was trying to find the best way to read only updated/changed data from AX for some entities like customers and vendors in D365. To do this in AX 2012 we would generally get a read only database copy made of  production, enable modifiedDateTime fields and query the recently changed data from that database for our reporting needs but in D365 a cool new feature has been provided called change tracking. Through this you can get AX to push changes to your records to an external database outside of AX. A brief overview of this is that we use data entities to list what we need pushed out and configure them to export to our database. Read more on this here:

In Data management:

Register read only DB outside AX, providing its connection string:


Change tracking options:

Creating a Data entity to export records for a Date effective Table in Dynamics 365 #Dyn365FO

When creating a data entity for a data effective table there are a few properties we need to consider for our imports and exports to work correctly. There can be two scenarios.

1. Data entity is not date effective but one or more data sources within the entity are date effective.

For example we have to export details of a Party record. Now the Party record is saved under DirPartyTable that is not date effective but its First, Middle and Last names are stored in DirPersonName table that is date effective. In order to make sure that we get the latest names of this party while exporting data we need to configure the entity to do so, else it will send whatever record is first in DirPersonName against the party record. To configure it we simply need to set the Apply Date Filter Property to Yes for DirPersonName and make sure we add the ValidTo and ValidFrom fields of DirPersonName datasource to the entity field list.

Parent data source DirPartyTable, not DateEffective:


Child data source DirPersonName, that is date effective:

2. Data entity is date effective

What this means is that our data entity has at least one date effective data source and itself implements the date effective framework. Keeps track of latest and old records rather than overriding existing records on update. Will discuss this further in my next blog.

For more information about date effectivity in data entities see: Date effectivity

Things to do while Restoring a production backup on a test or a Dev box in #AX2012

Once your db restore is done. Before starting services make sure you do the following:

Stop any batch jobs to avoid posting or pushing data to systems configured in production. This can be done by below SQL

UPDATE [DynamicsAXDev].[dbo].[BATCHJOB] SET [STATUS] = 0

WHERE [STATUS] IN (1,2,5) 


An Admin User would already exist, Use below query to set your user as Admin:

SET Name = ‘Mohsin’,
SID = ‘S-1-5-21-542508066-1570976776-XXXXXXX-54688’,
NetworkDomain = ‘XXXX.XX’,
NetworkAlias = ‘XXXX’
WHERE ID = ‘Admin’

Start services and replace the settings described in the video below to set your batch servers.

D365 Mystery Hosting Explained #Dyn365FO

Mystery: IIS was stopped but D365 app was still running. How could this be? Its a single box Azure VM and everything, not just the AOSService but ISS itself is off. I verified the app is connecting to the right database and verified the webconfig file points to my own server so some other machine could not be hosting the App, I checked all configurations and none point to a different server so what magic is going on here.


I’m sure this would not be a mystery for everyone but for a short time it became a mystery to me and might become to some others as well so I had to get to the bottom of the magic happening. After some research I got to know that after the recent platform update 12 D365 is hosted on IIS Express, and as you know IIS express runs on visual studio, so if you have Visual studio open your app will be hosted. I ran a few scenarios after this so here is a list of them.


  1. If Visual Studio is open, your IIS is stopped, D365 would still run on based on IIS Express.
  2. If Visual Studio is closed, your IIS is stopped, D365 url will give you a Service Unavailable error
  3. If Visual Studio is closed, IIS is running, D365 will run based of your AOSService site.
  4. If Visual Studio is Open, IIS is running, D365 will run.

Thanks to a post by Faisal here which lead me to this. It explains what else was done wrt to update 12 like elimination of Admin user on lcs and availability of a Developer user.


Mystery Solved!


Address and contact information table relationships to a party in #AX2012 & #Dyn365FO

Both address and contact information on a customer, vendor or any party record is stored at the party level. So while the parties Customer and Vendor are company specific the party record is cross company. If you create a customer against the same party in two companies and modify the address of Customer A in company X you will see the changes for Customer B in company Y. This is because when we are modifying a customers address or contact, it is actually modifying the party address and contact. You can test this out without getting into the development environment by creating a customer in one company with an address and contact, note down its party number that was created, then create a customer in another company and use the change party association option to assign the newly created customer the party number of the previously created customer. After this, change the address on any one of the customers and you will see the changes reflect on the other company customer as well. Now generally this is not the case as when you create a customer in a company a new party record gets created against it and within AX you always create a customer or vendor first and not a party itself.

Coming down to the technical’s in play for this. A party record is stored in the DirPartyTable and in order to query its locations(addresses/contact information) you can query the DirPartyLocation table which will give out  records that each represent an address and one record that represents all contact information records, to identify these there are NoYes enum fields such as IsPostalAddress. For example if there are 3 addresses on a customer and 5 contact information records, this table will show you 4 records. Each record contains a Location field that represents the RecId of  the LogicticsLocation table, this table contains links to the address and contact information records. Addresses are saved in LogisticsPostalAddress table and contact information is stored in LogisticsElectronicAddress table, each table has as relationship with the LogisticsLocation table as shown below.

Contains 4 records, 3 for addresses and one for contacts:

These records can be used to query the address in LogisticsPostalAddress table below, wrt to the following relationship:

Hopefully this gives you an idea of the crud operations of an address and contact information in AX. This applies to both AX 2012 and D365.

Change or Remove a dimension value on an Item through X++ in AX 2012

Using the below job you can update dimension values on an item.


static void UpdateDepartmentMISC_Items(Args _args)

InventTable inventTable;
DimensionAttributeValueSetStorage dimStorage;
DimensionAttribute dimAttDept, dimAttMisc;
DimensionAttributeValue dimAttributeValueDept, dimAttributeValueMisc;

DataAreaId company;
str misc, dept;
ItemId itemId;
int counter = 0;


info(strFmt('Start time: %1', time2StrHM(timeNow())));



inventTable = null;

dimStorage = null;

dimAttMisc = null;

dimAttDept = null;

dimAttributeValueDept = null;

dimAttributeValueMisc = null;

while select forUpdate inventTable

where inventTable.ItemId == itemId

&& inventTable.dataAreaId == curext()






dimStorage = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);

dimAttDept = DimensionAttribute::findByName(#DepartmentDimensionToUpdate);

dimAttMisc = DimensionAttribute::findByName(#MISCDimensionToUpdate);

dimAttributeValueDept = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttDept, dept, true, true);


if (misc)


dimAttributeValueMisc = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttMisc, misc, true, true);





inventTable.DefaultDimension =;






error(strFmt("Error to update dimension for item %1", inventTable.itemid));





info(strFmt("Records updated: %1", Counter));

info(strFmt('End time; %1', time2StrHMS(timeNow())));


Resolving: Error System.InvalidOperationException: Unable to recycle AppPool ‘AOSService’ running Site ‘AOSService’.

Recently I came across an error while doing a complete build on D365


Error :

Severity Code Description Project File Line Suppression StateSeverity Code Description Project File Line Suppression StateError System.InvalidOperationException: Unable to recycle AppPool ‘AOSService’ running Site ‘AOSService’. Check your IIS/Azure Environment for correct deployment. —> System.Runtime.InteropServices.COMException: The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)   at Microsoft.Web.Administration.Interop.IAppHostMethodInstance.Execute()   at Microsoft.Web.Administration.ConfigurationElement.ExecuteMethod(String methodName)   at Microsoft.Web.Administration.ApplicationPool.Recycle()   at Microsoft.Dynamics.Framework.Tools.AosAppPoolRecycler.RecycleAppPool()   — End of inner exception stack trace —   at Microsoft.Dynamics.Framework.Tools.AosAppPoolRecycler.RecycleAppPool()   at Microsoft.Dynamics.Framework.Tools.BuildTasks.SyncEngineWrapper.Sync(CancellationToken cancellationToken) 0


To verify that an application pool has recycled correctly, follow these steps:

Open Internet Information Services (IIS) Manager as an administrator.

In Connections pane, expand your computer name.

Open Application Pools

Find the AOSService pool and if it is stopped, start it.

app pool


Resolving Visual studio tools 2013 installation error in AX 2012 R3 CU8

When trying to install visual studio tools the following error occurs “This installation package could not be opened. Verify that the package exists and that you can access it” This is mostly caused by VS tools folder missing inside the msi folder of your installation setup. If these folders are there then you might have a different issue. To resolve this for R3 builds follow the following blog by Microsoft support:

After this simply run your installer again and add the visual studio component, worked like a charm for me!


Time taken: 40mins

Transfer Demo data into AX 2012 R3

For transferring demo data into R3 versions of AX 2012 follow the below:


1 Get Demo data package and extract it into any feasible  location (Extraction will be large about 15-20GB)


Takes 20mins
2 Get Data transfer tool to transfer package extracted data in AX DB <<>>

3 Import MetaDataXMLGenerator.xpo into AX environment and run the job


Take 30mins

This will be found in the Data transfer tools folder you extracted above
4 Copy Metadata file generated as output of the above job to the [Lists] folder in the Data Transfer tool directory File is mostly generated at the following path





5 STOP AOS before moving to the next step  
6 Open command prompt as admin. Go to directory where Test import tool was extracted.

Run the following command


Takes hours (2-3 approx.)


DP.exe IMPORT “C:\Users\mohsin.khalid\Downloads\MicrosoftDynamicsAXR3CU8DemoData” MicrosoftDynamicsAx



FYI; In above command “MicrosoftDynamicsAx” is your ax db name




  Total time of activity 4 hours approx