Code highlighting

Wednesday, September 24, 2008

Microsoft Dynamics AX 4.0 data model overview

I have great news for you, readers :)
Recently, on an internal Microsoft discussion group, I received a nice document with an overview of the data model for Dynamics AX 4.0.
After permission was received to publish this document to an external audience, I uploaded it to my personal web-site, so that all of you can download it at a convenient time.

The link is below. Enjoy!

Download AX 40 data model document
Download AX 40 data model document (Russian)


UPD: A newer version of this document does not exist, so I won't be able to post it here

Monday, September 22, 2008

SysMultiTableLoookup - dynamic lookups based on multiple tables

Wow! MSDN for Microsoft Dynamics AX is getting better every day. This is terrific news!! I still remember the days, when all the information was extremely hard to find. It had its own charm though :)
Anyway, this topic is really not about MSDN. It is about lookup forms.

First of all, for the record: I (and the Best Practices document as well) recommend creating custom lookup forms in AOT instead of dynamically coding them in the overridden lookup methods on controls/datasource fields.
But, in reality, this is true only for lookup forms with very large complexity. I won't go into a discussion of why that is the way it is here. :)

Now, back to what I was planning to write about:
In order to build a lookup form from code, developers use the SysTableLookup class.
You can go to MSDN (mentioned above) to read a How-to article on creating a run-time lookup form, as well as take a quick look at the SysTableLookup method descriptions.

SysTableLookup class has evolved over the multiple releases, providing more and more flexibility and control to the application developers.
I would like to publish another extension to this class, SysMultiTableLookup, which I hope will prove useful to members of the AX community.

Short list of features:
- Backward compatible, should cover everything that is present in AX 2009 version of SysTableLookup class
- Allows including multiple tables into lookups with different join types
- Completely based on the Query that you build, no extra parameters (except for the control) are needed to initialize the class
- Allows adding aggregated fields to the lookup
- Displays fields based on Boolean Enum as check boxes
- Allows to specify alternative labels when adding fields to the lookup

New download link, as Axaptapedia seemed to mess up the file

You can download the project from axaptapedia.com.


It has (to some extent) been tested on Axapta 3.0 SP3, AX 4.0 and AX 2009.

Also included in the project is a tutorial form, showing 4 examples of dynamic lookups using the new class. After importing the project, make sure to try out the form, and use it for future reference for code examples and other inspiration.

Tuesday, September 16, 2008

SysInfoAction class description - Improve your Infolog

In the last couple of weeks I have been asked about this a number of times, so I decided it would be a good idea to describe what the class can do for you.

In just a few words, this class helps you interact with your users better, helping them perform some desired action (predefined) on request. This will save some time for the user, providng for a better user

There is a number of classes already present in the system.
Just to name a few used the most:

JournalInfoAction - allows navigating to the specified journal line. This is used, for example, when checking the journal lines before posting.
SysInfoAction_Editor - opens the editor in the specified method on the specified line/column. Primarily used for development purposes.
SysInfoAction_FormRun - opens a specified form, setting focus to a specific control, if required. There are many extensions of this class, allowing for more control over what is to happen.
SysInfoAction_MenuFunction - same as the one above, but the input is a menu item that is to be launched on user action.
SysInfoAction_newWindow,SysInfoAction_AOTproperties - both are used to ease up the dev's life a bit. The first one opens the specified AOT object in a new window, the latter one - the properties for the object.

And so on...

I had to create one extension of this class yesterday as well, while doing a small tool we use inside our team. The requirements were to launch a specific external application, specifying a number of files as command-line arguments. WinAPI ShellExecute can do exactly that. So I create a simple wrapper around the WinApi::ShellExecute method that is accessible as an infolog action.

Here is an example of how this class can be used:



You can download the class from axaptapedia.

The output of the infolog, in this case, would look similar to this:

Infolog output


One other thing worth mentioning about these classes is the method infolog.infoActionObject(). This is not used as often, but provides a greater control over the infolog action by allowing interaction with an open object, like a form.
This is used in AX journals (Inventory Transfer journal, for a specific example, if you wish). Whenever you check the lines of the journal (before posting), you get an infolog in case of errors, which allows to navigate to the specific line with the error. The navigation occurs in the journal lines form currently open, which is much better than opening a new form for each line.
In order to use this, simply specify the object that needs to be available when executing the infolog action, using the method mentioned above, like the following:

infolog.infoActionObject(this); //if called from the method on a class/form, for example

For more information, check out the article on Axaptapedia (I hope it will get expanded over time :))