How to open AX with a User Role and debug it at the same time in Dynamics #AX2012

Recently came across a scenario where we had to debug a user session that had limited rights to the system, one way of doing that could be for instance walking through a trace of the user session and another would be to debug code while user steps through the process but that would be done only for server side calls. So what if we need to debug client side calls as well, how to go about doing that was the challenge. Since if we assign the user role to an admin and execute the process we also have admin privileges which are higher up the ladder and do not limit access to what that user role has. Not to worry there is a way you can do this by following the steps below:

1. Run Dynamics AX as an administrator
2. Add the role you want to debug to your own user, let the Sys Admin role stay as well.
3. Open a new development Work space.
4. Place breakpoints where you need them.
5. Create below job
static void NonAdmin(Args _args)
{
securityutil::sysadminmode(false);
}
7. Execute the above job
8. Open a new workspace
9. Run the process you wanted to debug.

You should now be able to hit the break point you placed in Microsoft Dynamics AX 2012 Debugger as the User role.

P.s I found this thanks to an old post by a colleague of mine.

 

Testing the Payable Skype Chat Bot to create and find a Purchase order in D365 #Dyn365FO

A chat bot recently developed by my colleagues Amir Nazim and Zain Khan at Mazik Global got me excited for how much room there is for enhancing the AX user experience and simplifying day to day tasks of an ERP end user. This chat bot right now enables you to find an existing purchase order in AX within a few seconds and also has the option of letting you create a purchase order in AX by answering a few questions of the bot. So if you are an end user that’s on the go or is finding it too cumbersome to open AX just to see details of a purchase order  you can simply hit up this bot and get it to do the work for you.  See the video below in which I talk to this bot to perform these tasks for me without having to say please. This showcases the true power of Odata entities and the bot framework.


For information on how to create a similar bot visit:

  1. Payable Bot Dynamics ax 365

  2. Purchase Order Chat-bot application with OData endpoints using WebApi in D365 for Operations

 

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 capture a Trace log of any process in Dynamics AX 2012

Often times debugging a process is not enough to identify a bug or a query that is taking too long or the scenario only happens on a specific machine be it production or test and we need to get to the bottom of what is wrong that causes the issue. This calls for tracing the process and stepping through each cycle as it happened, thanks to Trace parser and the tracing cockpit provided in Dynamics AX 2012 we can capture every query executed and method called during that process. In the below video I show how to capture a trace log of any process.

 

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: https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/entity-change-track

In Data management:

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

 

Change tracking options:

Error on MPOS sync jobs #Dyn365FO

Errors:

Failed try of uploading data package to blob storage, error message: System.Reflection.TargetInvocationException has been thrwon

connection could be made because the target machine actively refused it

The change tracking information related to scheduler job 1090 and channel database group Default are only partially available, due to the headquarters data base change tracking retention period settling.

 

Solution:

Make sure your azure emulator is running.

Solution: The Table.Field does not have a corresponding parm-method on the AxBC-class

If you have added new fields to an existing table and receive the below best practice error, it means you need to create a parm method. This can be automatically done with a simple one line code.

For example If we add the field below

We’ll receive the following error:

“The Table.Field does not have a corresponding parm-method on the AxBC-class”

Solution:

Create a job and execute this code below

static void Job8(Args _args)
{
AxGenerateAxBCClass::newTableId(tableNum(PurchTable)).run();
}

This creates the parm method which will not only get rid of the BP error but now you have your new field synced with the table creation field when an AIF service, a data migration entity or initialization is done.

How to check which IIS your AX Finance and Operations web App is hosted on in D365 #Dyn365FO

This can be done by going through the web.config xml file which is located at  “X:\AOSService\webroot”. Several parameters are configured here for for the application and i’ll go through some below, as a developer or administrator of Dynamics AX it is essential to know what configs are set here, so do give it a read and go through each element.

Hosting configs:

<add key=”Infrastructure.HostName” value=”usnconeboxax1aos.cloud.onebox.dynamics.com” />
<add key=”Infrastructure.HostUrl” value=”https://usnconeboxax1aos.cloud.onebox.dynamics.com/&#8221; />
<add key=”Infrastructure.SoapServicesUrl” value=”https://usnconeboxax1aos.cloud.onebox.dynamics.com/&#8221; />
<add key=”Infrastructure.InstanceEndpointIPAddress” value=”localhost” />
<add key=”Infrastructure.MaxInstanceEndpoint” value=”10010″ />
<add key=”Infrastructure.MinInstanceEndpoint” value=”10000″ />
<add key=”Infrastructure.PersistentVirtualMachineIPAddress” value=”localhost” />

Package directory folder settings:

<add key=”Aos.AppRoot” value=”C:\AOSService\webroot” />
<add key=”Aos.PackageDirectory” value=”C:\AOSService\PackagesLocalDirectory” />

Database info in the file:

<add key=”DataAccess.Database” value=”AxDB” />
<add key=”DataAccess.DbServer” value=”localhost” />
<add key=”DataAccess.SqlPwd” value=”XXX” />
<add key=”DataAccess.SqlUser” value=”axdbadmin” />

 

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:

UPDATE USERINFO
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.