Free: AN INTRODUCTION TO DYNAMICS AX 2012 (Dynamics AX Companion Guides)

2015-07-24_1435Its not really my habit in my blog to re-post or re-blog other users content, but rather to write up my own findings as I explore Dynamics AX. However this post is a bit of a worthy exception.

If you have been in AX for an period of time you have most likely heard of Murray Fife and his very practical Companion guides to Dynamics AX. Right now you can download his “AN INTRODUCTION TO DYNAMICS AX 2012″ for free over here. It is highly useful material for anyone new to AX or even old hats looking for some new easy to use tips and tricks. I’ve been compiling some introductory basic training material for our company and this book will go along way in assisting me with this!

Thank you Murray Fife for this awesome content.

See his original post over here too.

Update: Unfortunately this was only a limited time offer, but I would still encourage you to get hold of this book either from Murray Fife’s website or from amazon  Here

Setup DB Logging in X++ (Updating events)

Setting up AX Database logging via the user interface wizard can at times be a bit of a cumbersome and slow task, especially for tables that are not very common. The job below will simply set database logging for all fields on a specific table. Simply replace “InventSalesSetup” with the table name of your own choosing. As always, test this in a non-production environment to confirm that it performs suits your own needs.


Advanced AOT searching

Its always a great opportunity to interact with other AX developers and have the opportunity to learn from each other. A few weeks ago I published a blog post on searching the AX AOT in code for objects with specific properties, after the post went out I got a comment on the post of a much easier way to search the AOT from the frontend, that for some reason I have never really noticed before. So here is a quick way to do an advanced search of the AOT using a real situation I encountered this morning.

Example: Find all privileges in the AOT that have a specific menuitem as an entry point. e.g. “PurchFormLetter_PackingSlip”

1. Open an AOT and select the section of the AOT that you wish to search. Obviously the narrower the search the quicker it will be. I selected Security->Privileges.
2. Right click on the object. Click Find
3. Select “All Nodes” in the search dropdown
4. Select properties tab.
5. Right click on any field in the “Property” Column, Click filter by field.
6. Enter the name of the property you wish to search on. In my case I’m looking for all entry points that points that have the ObjectName set to PurchFormLetter_PackingSlip, so i enter “ObjectName”
7. Click Ok.
8. Click the “Selected” checkbox
9. Enter the value you want to search for under “Range” e.g. “PurchFormLetter_PackingSlip”
SelectProperty210. Repeat steps 5-9 if you want to search for multiple properties.
11. Click Find now
12. You will now have a list of all the subobjects of whatever you selected in step 1 containing a specific property with a specific value.


Note 1: You can also do some pretty neat searches using both the date and advanced tabs on this form so be sure to check them out too.

I hope this helps somebody who like me has just overlooked this for years.

Thanks Martin for the tip!


Disclaimer: For my specific example it may have been easier to use either the Security development tool or right click on the menu-item in AX -> Add-ins -> Security Tools -> View related security objects. But I needed an example for this post :-)

Remotely Controlling AOS services

I’ve recently moved into an environment with multiple load balanced AOSs that need to be controlled during code deployment and maintenance. If one needs to stop and start these services include either to logging into each machine individually or using the Windows services control panel to connect to the indivual machines to shutdown each AOS service.

Both of these options unfortunately are rather tedious and time consuming especially if you have numerous services to control and need to do it quickly. A simple way to do this is to batch/script the process using command line instructions to control the remote services. You can use sc.exe application to do so. Here are some examples:

sc \\[SERVERNAME] stop [SERVICENAME] e.g. sc \\JH-Srv-01  stop AOS60$01
sc \\[SERVERNAME] start [SERVICENAME] e.g. sc \\JH-Srv-01  start AOS60$01

This will issue the commands but won’t necessarily wait around while the services are stopping or starting.
Adding multiple of these commands to a single .BAT file will make you environment management life much easier! You can also use it to control other services like SSRS etc…

Note 1: You will obviously need the necessary permissions on each of these servers to do these tasks.
Note 2: The service name is the name listed under the properties (right click on the service, click properties) of the service not the one in the list of services.




10. My checklist for debugging X++ code

As part of my series on “Things new X++ Developers Should know”. I have been writing a few basic howtos and checklists for new X++ Developers. These are really meant to be simple step by step guides to get new developers more productive by exposing the little secrets of the AX development that sometimes take years before discovering.

Today’s post is a checklist of things you need to have in place to ensure that you can debug X++ code.

  1. Enable debugging for your user. In an AX development window click on the tools menu item, then click options. Click on the development fast tab. Under debug mode set the option to “When Breakpoint”Enable_AX_Debugging
  2. Ensure your user is part of the local “Microsoft Dynamics AX Debugging Users” user group. On the machine which you are running the debugger on Edit your users and groups.
    Expand the “Groups” section and double click on “Microsoft Dynamics AX Debugging Users”. Click “Add” and enter your domain name and click ok.
    2015-05-25_1546You will need to restart your user session by logging off and back on again
  3. Ensure the server is enabled for debugging (needed for serverside code). Open up the Microsoft Dynamics AX Server configuration console from Windows administrative tools. On the “Application Object Server” tab enable “Enable breakpoints to debug X++ code running on this server” and “Enable global breakpoints”
    Enable server breakpoints
  4. Enable client debugging options (optional/advanced for business connector debugging). In the Microsoft Dynamics Client configuration console in Windows administrative tools enable the following: “Enable user breakpoints to debug code in the Business Connector and Enable global breakpoints to debug code running in the Business Connector or client.
  5. Ensure the debugger is installed on the client machine. Run the Microsoft Dynamics AX installer and ensure the “Debugger” (found under development tools is installed)
  6. If your code is running in CIL:  You can either follow the steps listed on MSDN or for simple debugging (i.e. logic errors) set your user to not run business logic in CIL via your user options form:
  7. Finally and most obviously you need to create breakpoints. You can do this in three ways.
    1. Navigate to the line of code that you want to debug. Press F9
    2. Navigate to the line of code and press the “Red circle” on your toolbar.2015-05-26_1502
    3. Finally you can physically type “debug” in your code to create a breakpoint. However this will enable it for all users in the system, not just for yourself.

I hope this checklist will help somebody stuggling with their debugging in AX. Please let me know if there are additional tips for debugging that this list may be missing.

For some additional details on debugging see MSDN:

14. Using Alt+[Up/Down] to rearrange the order of elements in the AOT.

As part of my series on “Things new X++ Developers Should know”. I have been writing a few basic howtos for new X++ Developers. These are really meant to be simple instructions to get new developers more productive by exposing the little secrets of the AX development that sometimes take years before discovering.

Today is the simple trick of moving elements up and down in list in the AOT using your keyboard. E.G. Re-arranging fields in a grid control or field group. Sometimes the mouse re-arranging produces unexpeded results and is quite frankly much slower.

  • Simply highlight (click on) an element of an object that makes sense to re-order e.g. a column in a form grid.
  • While holding in the “ALT” key use the up and down arrow keys of your keyboard to move the object up and down in the list


Notes on this functionality:

  • This functionality only works where it actually makes sense i.e. where where order actually matter like on grids and field groups. E.G. Moving your control above “methods” (in the screenshot) will have no effect and will automatically move it back down to directly below “methods” on re-opening the aot element.
  • This functionaly will do nothing on set elements in an Object e.g. “Methods”, “Datasources”, “Designs”, “Parts” etc…
  • If you’re a little OCD like myself and would like to re-arrange the fields (in the fields node) on a table object they will move when using Alt+[Up/down], but the change will not be permenant, even after saving. Field order doesn’t really make much difference in AX, apart from readability in the AOT. So if you want the primary key to be at the top of the list, then you must create it first (I haven’t found a workaround yet).
  • The same applies for ordering of methods in classes. The methods physically move but the change is not permenant
  • As above, even though you are physically able to, reordering the tables in the AOT makes no difference. They will always be revert to being alphabetical after re-opening the AOT.
  • Re-ordering objects in an AX development project does work! The elements will stay in the order that you arrange them.



8. Locate specific AOT object without scrolling

As part of my series on “Things new X++ Developers Should know”. I have been writing a few basic howtos for new X++ Developers.

Today’s post relates to quickly navigating to specific objects in the AOT without endless scrolling.

So often when working over the should of new developers or consultants exploring the AOT I see them scrolling endlessly or dragging the scrollbar back and forth for a while before finding the object they are looking for.

A common technique to navigate through lists in both Windows (e.g. My computer etc) and windows based environments (SQL management studio etc..) is to simply start typing the name of the object you are looking for. Windows automatically moves to the first object matching the sequence typed.

AX is by no means an exception to this rule. Simply click and expand the main node of the object you are looking for e.g. “Forms”
AOT Navigation Forms
and start typing E.G. “PurchReqT…..”
As you type AX will move to the first object found matching what you have typed so far..
E.G. P moves to PartitionAdministration,  Pu to PurchArgreement etc….

There are some bonus features when using this in AX:
1. You can always see what you have typed so far by looking at the bottom left of your screenAOT_Navigation_Status_Bar
2. The typing timeout is long compared to applications like SQL etc where you need to have taken a speed typing course to get this right. As long as you still see the search term in the bottom you can just continue typing (this normally takes around 7 seconds or until you use your keyboard arrows or mouse to do something different

I know this may be a very obvious tip, but I’ve witnessed too many people taking forever to find objects by scrolling to not include this in the “Things new X++ Developers Should know” series.



4. Drill through to code from Info log

As part of my series on “Things new X++ Developers Should know”. I have been writing a few basic howtos for new X++ Developers.

Today’s post relates to quickly navigating to the source code from where an info log error, warning or information message is called from.  It took me a while to figure out that for many info log messsages you can simply double click on the message in the info log window and the code that called the message will be displayed for you.

E.G. If you see the normal error log icon or warning icons with a small arrow in the bottom left corner, you are normally able to double click the message to see the code behind it. These icons look like this:


Error Log

Infolog Info

Info Message

Warning Message

Warning Message





Simply Double click the message as below


To be presented with the code that called it.



NOTE 1: If you have your “Execute business operations in CIL” user option enabled, a lot of business logic like postings etc will not allow you to drill down.

NOTE 2: If the code calling the info message makes use of the SysInfoAction parameter, you will be taken to an alternate form specified by the developer and not the source code. (See Axaptapedia Article)

3. Drilling down to the parent type of an object in the AOT.

As part of my series on “Things new X++ Developers Should know”. I have been writing a few basic howtos for new X++ Developers.

Today’s post relates to quickly navigating to the source or parent type of an object in the AOT. This is often useful to drill through to a parent object to discover, debug or modify properties and code. The following are some examples of drill-downs you can perform

1. Open the Data Dictionary Table from a Form’s datasource
2. Open the Data Dictionary Enum used from a table field
3. Open the Extended Data Type used by a table field
4. Open the AOT Form object (or class, report etc) from a Menu-item object
5. Open the Data Dictionary Table object from a Query datasource
6. Open a parent EDT from an extended EDT
7. Open a parent class from an extending class.


1. Open the object in question e.g. a Table field.
2. Right click on the field.
3. Select “Add-ins”
4. Select Open new Window
5. Click “Open used Extended Data Type”

6. The parent type is now displayed in a new window. In this example the ProjId EDT is displayed

7. Determine Field name of control on an AX Form

As part of my series on “Things new X++ Developers Should know”. I have been writing a few basic howtos for new X++ Developers.

With some of the more complex forms in AX 2012 it can sometimes be quite tricky to navigate through the form hierarchy in the AOT to debug which table and field certain controls on your form are bound to. So today I’ll cover how to determine the Table and Field name or the name of a control directly from an AX Client form. A quick and easy way to do so is to simply use the “personalise” function in AX.

NOTE: This requires you to have system administrator privileges (which you probably have if you are a developer)

1. From any form in AX. Right click on the form control or field that you would like to diagnose.
2. Click “personalise”


3. From the personalise screen you can now view the following:



#1. The location in the Design node of the AOT where the control resides
#2. The name of the Control in the AOT
#3. The name of the AOT Table name that the control is bound to
#4. The name of the datasource on the form that the control is bound to (normally the same as the Table Name)
#5. The name of the field on the table that the control is bound to




2. Drilling down to the AOT from an open form

As part of my series on “Things new X++ Developers Should know”. I have been writing a few basic howtos for new X++ Developers.

Today we cover how to determine the AOT name of the current form that you are accessing and edit it directly without having to go through the tedious process of navigating/searching in the AOT. This can be very useful in increasing productivity as well as debugging functionality

1. From any form in AX right click on an control.
2. Click “Personalise”.



3. Select the “Information” tab.
4. The AOT name of the form is visible under “Form name”.
5. Click Edit to acess the form in the AOT.

Note: This won’t work for forms created in code like dialogs etc..

Things new X++ Developers should know

developer-iconSince my start in X++ development over 6 years ago there are many small things that I have learnt that I wish I had known from the start. Small things that won’t necessarily help you post a stock journal from code or perform complex integration tasks, but none the less makes your day ever so much more productive. If you are a seasoned developer you will most probably already know most of these, but I thought I’d put them all down in a neat list for new guys to go through. Here are some of my favourites along with links to short articles on how to do them. (I will hopefully add some more over time).

1. Keyboard Shortcut to view properties of an AOT element: Simply Hit “Alt+Enter” on any AOT element to view its’ properties list. Much quicker than fumbling with right clicking on the mouse. (view more shortcuts)
2. Drilling down to the AOT from an open form: Instead of reverse engineering forms from menu structures or navigating in the AOT to edit a specific form, simply right click on any form, click “Personalise”, select the “Information” tab, click on the “Edit” button next to the form name. (view details)
3. Drilling down to the dictionary type of an object in the AOT. E.G. Edit enum or EDT being used by a field on a table. Navigate to an element in the AOT e.g. A enum field on a table. Right click on the element, click “add-ins”, click “Open in new Window”, click “Open used Enum” etc…. (view details)
4. Drill through to code from Info log – Quite often the info log will allow you to drill down into the code the called the error message. If you notice a small arrow on the error icon you can simply double click on the line to take you to the code. (view details)
5. Infolog code drill down does not work if code is running in CIL. As an addition to the above you will not be able to drill down to code if it is running in CIL. For DEVELOPMENT/DEBUGGING purposes only you can simply disable code from running in CIL in your User Options.
6. Run AX as an alternative user. For debugging security or processing workflow it is often needed to run AX as an alternative user. Simply press Shift and right click on the AX icon on your desktop. You can then select “Run as different user”. (view more)
7. Determine Field name from control on Form. Sometimes you need to quickly find out the database table and field that is shown on a form without navigating through the complex AOT form. Simply right click on the field, click “personalise”. Under “System Name” you will see the following: Control name, Datasource Name, Table Name and finally Field Name. (view details)
8. Locate specific AOT object without scrolling. This may be an obvious one as Windows uses this technique in many other applications. Open the AOT and expand and click on the main node of the object you are looking for e.g. Classes. Then simply type the name to navigate to the specific object. (view details)
9. Creating an Development Environment shortcutAs a developer you don’t necessarily want to login to the Dynamics AX front end whenever accessing the AX shortcut, but rather want to open a development workspace directly. To do so right click on the AX shortcut on your desktop, click properties, on the shortcut tab in the “target” field add “-development” after the path to the Ax32.exe file. (View step by step)
10. Enabling breakpoints / debugger. One of the most important tools in a developers toolbag is the debugger. There are a few items on the checklist that you should ensure before you can successfully debug code: View them here.
11. Enabling viewing of Layer and Models. In a complex AX environment it is very useful to know what model and layer an object forms part of in order to search for patches or fix yourself. You can easily enable the AOT to display these by navigating to: File -> Tools -> Options -> Development -> Application Object Tree -> Application Object layer -> Select “Show All layers” and Application Object Model -> “show on All elements”.
12. AX Layer Config files. Create AX shortcut files to allow you to easily logon to the layer of your choice. View how here. (link available soon)
13. Profiler / SQL Trace. You can easily make use SQL Tracing or profiler to see the exact SQL being executed behind the scenes. This can be very useful for debugging purposes. (link available soon)
14. Using Alt+[Up/Down] keys to reorder AOT elements. To rearrange object elements like controls on a form grid simply hold in ALT and press the Up and Down keys to rearrange its order in the parent. (view details)

Anyway thats my list for now. Please let me know of any other quick tips and tricks that you think new developers (or old) should know about!

Keep a lookout for some more detailed explainations on some of these coming up in the follow days.

For some more advanced tips, tricks and coding patterns please also checkout the knowledge base at


Finding orphaned Records in tables using RefRecId

Dynamics AX makes us the RefRecId, RefTable and RefCompany data pattern in a number of tables the system to provide flexible linking from a common/generic table such as WorkflowWorkitemTable to a variety of specific tables such as PurchReq or PurchTable.

Examples of this include Workflowtables, DocuRef, SpecTrans,  etc…

From time to time you may want to identify which of the records in these tables have become “orphaned” i.e. the documents that they refer to no longer exist. To do this in a fairly generic way you can make use SysDictTable’s makeRecord functionality as below (Using DocuRef as an example)

static void Check_Orphans(Args _args)
SpecTrans specTrans;
DocuRef docuref;
counter i;
Common record;
SysDictTable table;

while select forupdate * from docuref// where SpecTrans.RefTableId == 865 && SpecTrans.RefCompany==’an’// 866 for Debtors
table = new SysDictTable(docuref.RefTableId);
record = table.makeRecord();
select firstonly * from record where record.RecId == docuref.RefRecId;
info(strFmt(“Record %1 has been orphaned”, docuref.caption()));
//Delete if necessary over here…
info(strFmt(“%1 orphaned records found”,i));

I hope you find this a useful trick in your AX wanderings.

Adding code templates/shortcuts in AX 2012

If you’ve got any blocks of code that you use frequently, e.g. specific comment blocks, you can very easily add code short cuts in AX 2012 to auto-insert the them in to your X++ code.

For example you can setup AX to automatically create surrounding comment such as

whenever you type “mycom” and press the tab key.

How do you accomplish this. Very easily!

Step1: Locate the class EditorScripts in the AOT.
Step2: Create a new method with the format public void template_flow_[shortcut](Editor editor)
Step3: User the editor parameter to add code the code that you would like inserted. e.g. editor.insertLines(“\\test comment”);
Step4: Add your method to the case statement in the isApplicableMethod method in the section relating to template “editor scripts that does not apply to Macros” 

Thats it, now if you type your shortcut into any editor in AX and press tab, the “\\test comment” code will be inserted.

Here’s a full example method

The above creates the following output:


Repost from my old blog:

Mass Reassign Workflows

Challenge/Problem: Many Dynamics AX Workflow work-items that need to be reassigned at once.

Description: At times we have had the request from clients to reassign many workitems from one person to another. My first reaction is why weren’t delegation parameters setup on the user so that one doesn’t need to manually reassign. However I have come to realise over time that there are a couple of good reasons to do so such as a person falling ill suddenly, a mistake in the workflow config, failure to set delegation parameters in time etc…

Solution: The following script/job designed for AX workflow will reassign workitems from one user to another. You can modify your query a bit to restrict the items to just the one that you want. The attached one simply reassigns all items currently assigned to user “123456” to user “654321”.

NOTE: This will not affect items in your workitem list as a result of queues

Mass Resume Line Workflows

Challenge/Problem: Many line level workflows that need to be resumed.

Description: Sometimes due to data or setups one may have numerous line level workflows failing and entering a “Stopped” state. This may be a result of calendars that do not have enough dates created, users who have been disabled etc… If the workflows were header level, it is easy enough to select all in the Workflow History form and click resume, however on line level workflows one needs to view each line level workflow individually and resume them.

Solution: The following job can be used to perform mass resume on stopped workflows. You can adapt the SQL to limit to certain documents or document types of necessary.

Determine which users have outdated AX client versions

Problem / Symptom: You want to ensure that all your users’ Dynamics AX clients are updated to the correct rollup.

Description: You may have recently upgraded your Dynamics AX Kernel or Application to the latest Cumulative Rollup (CU), you’ve applied it to all of your AX Client installations that you are aware of but you would still like to make sure that nobody is logging into AX on an old version and potentially causing some problems. You may also be receiving an error in your AOS event log that goes something like this

Object Server 01:  Internal version mismatch. Microsoft Dynamics AX client from [MACHINENAME] ( tried to attach with 6.2.1000.4051 revision of kernel.

Solution: (Applies to AX 2009 & AX2012) There is quite a simple solution to this issue.

  • Open up any Dynamics AX client connected to the AOS in question.
  • Navigate to System Administration -> Enquiries -> Users -> User log
  • Right click anywhere in the grid, click personalise
  • Click “add fields”
  • Expand “User log”
  • Select “Build number”, Click Add

Screen Shot 2014-07-25 at 4.02.20 PM

  • Close the Select Fields form
  • Close “Personalise Form”

Your User log form will now show all sessions and their build number. You can now browse and field all sessions that don’t have the same build number as your kernel. You can also further filter this form to only show the non matching records by right clicking on the Build number field and entering “![buildnumber]” (see screenshot below)

Screen Shot 2014-07-25 at 4.08.14 PM

Click on the “General” tab to find out which computer/workstation the invalid session was coming from. You can now go and run the updates.

Screen Shot 2014-07-25 at 4.10.02 PM

Running Dynamics AX as an alternative User – Quick Tip

Problem / Symptoms: Users need to test Dynamics AX setups as different users.

Description: Quite frequently we are finding the need to test/run Dynamics AX as a different user from our default login user but do not want to run multiple remote desktop sessions or have to log in and out of our current session. We may need to do this for a number of reasons e.g. Testing a workflow approval process i.e. login to approver as the relevant user, Testing security permissions, Testing SSRS permissions, getting screenshots of AX for documentation with a different profile etc…

Solution: There are a number of ways to do this, I have been using CMD/DOS scripts to do this for years (more on this below). But I just found the simplest trick in the book:
1. Locate a shortcut (won’t work for config files) to Dynamics AX,
2. Right click, if you’re lucky (depending on operating system) you will see a “run as a different user”. Select this option, enter your user details and AX will run as this alternative user
3. If there isn’t a “run as different user” option, simply hold in shift and then right click, you should now see the “Run as different user option”

Run as different User


Alternate Solution:
If you are running via config files this solution will not work, you will need to first create an AX32.exe shortcut that takes the config file as a parameter E.G.

You can also create a .bat file with the following code: