Wednesday, April 25, 2007

My blog is now a Dynamics AX Related Community

As of today, my blog is present on the page of Microsoft Dynamics Related Communities.
You can see the list of related communities if you follow this link

Dynamics AX Tutorials - Tutorial 2 - Classes\Box

Here is a small project demonstrating capabilities of the class BOX in Dynamics AX.
Specifically, the following is covered in this tutorial:

  1. A short description of the system class BOX
  2. Creating a form from a class (using classFactory), launching different form methods, waiting for the form to be closed by the user and returning the selection
  3. Differences in implementation between DAX 3.0 and DAX 4.0

You can download the project from the following link:

  • download (for Dynamics AX 3.0 - only user layer)
  • download (for Dynamics AX 4.0 - only user layer)

Classes\Box is a simple class used throughout the DAX application. It provides an interface for showing a standard dialog with a number of selection options and a short message. This is very useful, especially during development, because it provides a fast way to show some kind of text information to the user.

The class contains a number of methods that can be extended with new ones (as shown below). All the methods are static and have the keyword client in the declaration, which forces the code in them to be executed on the client side.

The most commonly used methods of this class are:

  • box::info("message"); (for debugging purposes),
  • box::warning("message"); (for showing a warning message that the user won't miss)
  • box::yesNo("Message", dialogButton::Yes"). (for allowing the user to select the course of action for the underlying business logic)

All the methods mentioned above are simply creating an object of class DialogBox, which is system and doesn't allow to see its implementation. This class is therefore not covered in this tutorial.


The rest of the methods is rarely found in the application code, and is suited for specific situations where you need to provide the user with the option of choosing from more options. (for example, when imporing a project, you see a dialog created by the method box::yesAllNoAllCancel();

The implementation of these methods is very much alike: (example mentioned above)

client static DialogButton yesAllNoAllCancel(str _text, //message
DialogButton _defaultButton, //default dialog button
str _title = "@SYS11132") //dialogTitle
Form form;
Args args;
Object formRun;
args = new Args();; //form SysBoxForm is used to show the message
formRun = classFactory.formRunClass(args); //creating a FormRun object
formRun.init(); //calling init of the form
formRun.setTitle(_title); //setting title of the form (caption)
formRun.setText(_text); //setting message
formRun.setType(DialogBoxType::YESTOALLNOTOALLBOX); //setting the type of the form
formRun.setDefaultButton(_defaultButton); //setting the default button; //calling run of the form
formRun.wait(); //waiting for user action
return formRun.dialogButton(); //returing the user selection

The example creates 2 objects that are needed to run a form from code:
Args args - not discusses here (used to specify the name of the form that is being created)
Object formRun - that is the actual object of the form being created.

You might have noticed that it is of type Object and not FormRun. (using the base type)
This is done on purpose, as there is no compile-time validationg of methods actually existing on the form. If the method doesn't exist, you will receive a runtime error, which is not really appropriate in a live environment. So in your code you should chech that the methods being called do actullay exist. (Global method formHasMethod can be used for this purpose)

After the form is initialized and all the setMethods() are called, the Run() method is called. This method executes the form and shows it on the screen.
After the Run Method we see a call to formRun.wait(); This method notifies the RunTime that the code execution should stop here and wait until the form is closed. (if this method is used on a form to call a child form, the parent form cannot be closed before the child form)
[Note: The alternative method here is the detach method (behavior of MenuItem calls)]

After the user closes the form, the dialogButton method on the form is called to return the selected value. [Note: Notice, that the methods on the form are still accessible, even though the form is already closed by the user. This happens because the formRun object is not yet destroyed]

I added another method to the box class - yesNoWaitForm. It opens a form that looks kinda cooler than the standard forms, because it has the option of autoclosing after a set period of time. Well, everyone can find his own uses for this form. The form name is Dev_SysBoxForm and it is an almost complete duplicate of the system SysBoxForm form. The only big difference is that this form is set modal, and that the text of the default button is appended with the remaining amount of time before the form is autoclosed. [Note: SetTimeOut method is used, which is not covered in this tutorial]

There were differences in implementation (compared to the sytem form SysBoxForm). The main are listed below:
  • DAX 4.0 already has a modal window option (wait(TRUE)); So custom methos are removed from the form
  • DAX 4.0 has the minimize and maximize system buttons visible on the dialog form, and they had to be turned of on the form design.
  • In DAX 4.0 The return value of method formRunObj.dialogButton() was not automatically converted to the correct type. So an extra variable way added to the method to convert the result to a specific type of DialogButton. [Note: I think that this is a bug]
  • The font size of the html (message) was increased by 1, because the default font size seems too small to read.

The project also includes a job that contains a couple of examples of using the new method. Enjoy!

Thursday, April 19, 2007

Two very useful projects for DAX

1. DEV_FormControlInfo
Today I downloaded a very nice project for DAX 4.0 from
It inserts a number of lines of code into the SysSetupFormRun class, method task, providing a hotkey to access usefull information about any control on a form.

The hotkey is 'Ctrl + Q'.
Here is a screenshot of the result:

I moved the project to DAX 3.0, because I liked it a lot. Previously I used the Tabax button, which is convenient too, but does not provide as much info as posted above.

Here is the download link for the project:

2. DEV_AxFind

Also, my friend AndyD created a very good project for DAX 4.0

Description: After moving to DAX 4.0 a lot of users complained about the 'Ctrl + F' key combination. Now, instead of a 'Filter by Field' operation it opens a 'Global Search' window, which is uneasy to use so far.

Anyway, AndyD created a small dll file that replaces the 'Ctrl + K' key combination with the 'Ctrl + F' key combination, leaving the 'Global Serach' intact, but, at the same time, providing a well known interface for DAX users.

Thanks again, AndyD. :)

All you have to do is download the dll file (donwload link) and add the following lines of code into the Info class:

2.1. Info\\classDeclaration
DLL dllAxFind;

2.2. Info\\startupPost
void startupPost()
InteropPermission perm = new InteropPermission(InteropKind::DllInterop);

// DEV_AxFindReplacement Replace Keys F and K when used with the Ctrl key 19.04.2007 IKASH -->
dllAxFind = new dll(@"D:\Install\Dynamics AX\Dynamics AX 4.0 SP1 EE\axfind.dll");
// DEV_AxFindReplacement Replace Keys F and K when used with the Ctrl key 19.04.2007 IKASH <--

Notice, that the path to the DLL file, specified above, will be different - insert the correct path to the DLL file instead.

Reboot the DAX client. And you are done.

Friday, April 13, 2007

Buy MorphX IT in Russian

Now you can buy the MorphX IT (by Steen Andreasen) book about Dynamics AX Development in Russian language as well.

Please visit to order the book now (Paperback or download versions available)

Also, there is a special offer for people living in Kiev, Ukraine and Moscow, Russia.
You can contact

  • Ivan Kashperuk to order a paperback copy of the book to be delivered to Kiev.
  • Mihail Rzevsky to order a paperback copy of the book to be delived to Moscow.
This is a very good offer, as you will save a lot on delivery costs and book price. Also, you can get it signed by the translator on location FOR FREE! :)
Also, you should understand, that this is simply about helping people to buy the book, it is not a commersial affair, as translators won't get any or very low revenues from this.

P.S. also provides a review of the book and a free sample chapter preview.
P.P.S. You might have to wait for the delivery for some time, as orders are processed only after a certian quantity is collected.

Saturday, April 07, 2007

Add-On: Extended SysTableBrowser

Hello, readers.
Today I provide you with another tool for Dynamics AX developers. It is a modified version of the SysTableBrowser (See picture 1).
picture 1

After importing the project refresh the AOD (Tools\Development Tools\Application Objects\Refresh AOD)


  1. The table browser does not change its position when a different setup is selected. (Unlike standard system behavior in DAX 4.0)

  2. The AutoReport option was extended, and now you are able to select any of the table field groups (See Credits).

  3. Another selection option was added, providing the means to select any of the table fields to be shown in the grid. To do this, just press the ‘Select Fields’ button and select the fields you want displayed (See picture 2).

  4. Added a list of presets for the SQL window. (SELECT, UPDATE, DELETE). The list can be easily extended to include other presets you often use.

  5. Extra logic was added to the ExecuteSQL button, which executes the SQL string that the user has put into the SQL window. If it is a simple select (for example, generated by the SELECT preset), the ds query is executed instead of the sql string. This will bring back the sorting and filtering options that disappear after using the sql string query.
  6. Added the ability to sort columns by name or by id. In some cases (when, for example, you cannot find a specific field) it really helps out! (See picture 3)

picture 2
picture 3

Possible future improvements:

  1. Add display methods of the selected table to the list of fields in the select dialog.


The modification was inspired by a similar one performed by Nicolai Hillstrom for Dynamics AX 3.0. I moved it to DAX 4.0 and added some extra features I considered useful. One of them is implemented here (even thought I wasn’t able to download it and see how it is programmed).