Code highlighting

Saturday, May 07, 2011

Tutorial: Table Relation properties in AX 2012

As many of you already know, Microsoft has put in a lot of effort into normalizing the tables in AX 2012 and consolidating all the data modeling tools in one place - the table itself. As part of this effort, a number of new properties have been introduced on Tables, and in this post I would like to cover some of them, namely the properties on Table Relations.

The new properties you will find on a Table Relation in AX 2012 are:
  • Cardinality
  • RelatedTableCardinality
  • RelationshipType
  • Role
  • RelatedTableRole
  • UseDefaultRoleNames
  • CreateNavigationPropertyMethods
  • NavigationPropertyMethodNameOverride

Hua Chu from the AX team has written a Guideline document, explaining how these properties should be set for Relations you add to Tables in AX. Note that in AX 2012 most of the above information is not actually used at runtime. This is something that will happen in future releases.
I have modified the document so that it contains the information relevant for partners and customers extending the standard application and have uploaded it to my OneDrive.

The document requires certain knowledge of Entity Relationship Modeling (ERM) and UML notation.

Disclaimer:
This document is intended as a guideline only, and should not be used as a Step-by-Step instruction.
Changes to any of the described functionality might still happen before AX 2012 RTM.


Your feedback and questions are, as always, welcome.

Thursday, May 05, 2011

Tutorial: lockWindowUpdate() vs. lock()/unlock()

There are two method pairs in X++, that are used throughout the application by everyone writing some processing on application forms. These are:

element.lock();
element.unLock();


and

element.lockWindowUpdate(true);
element.lockWindowUpdate(false);


Now, not that many people know the difference between the two methods, and only very few think about why and when should each of them be used.
I will try to describe the behavior of these methods and at the end give some recommendations on how to use them. I have done some kernel code reading (with help of kernel dev. Andy Stach, who I would like to mention here), so what I write below is more or less backed up by code.
If you disagree with some of the recommendations though, please share your experience in using these methods through comments for this post.

FormRun.lockWindowUpdate()

is basically a wrapper around the LockWindowUpdate Win32 function. What it does is pretty simple:
When a window is locked, all attempt to draw into it or its children fail. Instead of drawing, the window manager remembers which parts of the window the application tried to draw into, and when the window is unlocked, those areas are invalidated so that the application gets another WM_PAINT message, thereby bringing the screen contents back in sync with what the application believed to be on the screen.
See the link on MSDN for a detailed description.
Note, that according to MSDN, it should not be used for general purpose suppression of redraw operations, but only when dealing with drag&drop operations. This does not hold true for AX, where this method is used all over the place to prevent redraw of controls on the form.
Another interesting point is that only one window can be locked at the same time. So, any nested calls to lockWindowUpdate will be ignored, but when unlocking, only the outer-most unlock will actually invoke the Win32 counterpart. Now, I have not seen this used in X++, which is for the better.

FormRun.lock()

is internally invoking lockWindowUpdate to prevent the redraw of the window, and then also prevents the IntelliMorph control layout engine from running. This is commonly used in scenarios where control properties affecting control arrangement are being set in a loop, which provides a performance optimization as it avoids redundant arrange calls being processed. On the other hand, when calling FormRun.unlock, more work will need to be done, compared to using lockWindowUpdate(false), where the control layout changes were actually processed by the layout engine, but simply not displayed.

So, based on my investigation, I would suggest to use the following recommendations when doing form development:

  • When formRun.resetSize() is used, specifically, when some controls become visible, increasing the form size, always use formRun.lock()/unlock(), otherwise the change in the size of the form might not get reflected on the screen correctly.
  • When changing multiple layout properties (Left, Width, etc.) on one or more controls, use lock/unlock
  • When you modify the properties that do not impact the layout of controls on the form, use formRun.lockWindowUpdate(), or, if there are only very few control properties being modified, do not lock the form window at all.

Monday, April 11, 2011

Microsoft Dynamics AX 2012 Beta now available for download - please share your feedback

As some might have noticed, I was quiet for quite some time now. I won't go into much detail as to why. What I want to say is that I along with a number of dedicated people have been hard at work on the release of a solution for Process Manufacturing and Distribution industry, which is also available in Beta through the below links.

Those of you working in this industry, I would be grateful for your feedback on our work so far, as well as any bug reports or design change requests for the RTM version or future releases.
Any other feedback, especially on the development tools and environment, is also welcome, of course.


Virtual Machine: 

https://mbs.microsoft.com/customersource/downloads/servicepacks/AX2012DemoToolsMaterials


Installable bits (ISO & IS IExpress pkgs):

https://mbs.microsoft.com/partnersource/support/selfsupport/productreleases/AX2012Beta

MSDN Dev Center:



TechNet Library:

Thursday, September 23, 2010

Tutorial: Undocumented behavior of kernel functions min()/max()

I was recently reviewing some code written to be shipped with AX6, and noticed an unfamiliar pattern being used in it. I investigated a bit deeper, and turns out it actually works fine on previous versions of AX as well.


I am talking about 2 kernel functions for finding the maximum or minimum of the specified values.
The signature of these methods is shown on the below image:


As you can see, it takes 2 arguments of anytype, and returns an anytype which is the largest of the two values. But it can accept much more than 2 arguments, even though it is not documented as such.

I wrote a small job to showcase this behavior. The code is provided below. You can also download it from my SkyDrive Dynamics AX share.

static void Tutorial_MinMaxFunctions(Args _args)
{
    #define.ArraySize(11)

    Random  rand = new Random();

    int     counter;
    int     arrayInt[#ArraySize];
    str     arrayIntAsString;
    int     arrayIntMaxValue;
    int     arrayIntMinValue;
    ;

    for (counter = 1; counter <= #ArraySize; counter++)
    {
        arrayInt[counter] = rand.nextInt();
        if (arrayIntAsString)
            arrayIntAsString += ', ';
        arrayIntAsString += int2str(arrayInt[counter]);
    }
    info("Generated array of integers: " + arrayIntAsString);

    info("The typical way to find a maximum is by looping through all the values one by one, calling the comparison function multiple times");
    arrayIntMaxValue = minint();
    arrayIntMinValue = maxint();
    for (counter = 1; counter <= #ArraySize; counter++)
    {
        arrayIntMaxValue = max(arrayIntMaxValue, arrayInt[counter]);
        arrayIntMinValue = min(arrayIntMinValue, arrayInt[counter]);
    }
    info(strfmt("Max.value: %1 and Min.value: %2", int2str(arrayIntMaxValue), int2str(arrayIntMinValue)));

    info("Using max and min with 11 arguments works just as well");
    arrayIntMaxValue = minint();
    arrayIntMinValue = maxint();
    arrayIntMaxValue = max(arrayInt[1], arrayInt[2], arrayInt[3], arrayInt[4], arrayInt[5], arrayInt[6], arrayInt[7], arrayInt[8], arrayInt[9], arrayInt[10], arrayInt[11]);
    arrayIntMinValue = min(arrayInt[1], arrayInt[2], arrayInt[3], arrayInt[4], arrayInt[5], arrayInt[6], arrayInt[7], arrayInt[8], arrayInt[9], arrayInt[10], arrayInt[11]);
    info(strfmt("Max.value: %1 and Min.value: %2", int2str(arrayIntMaxValue), int2str(arrayIntMinValue)));

    info("Note that comparing an integer and a real also works, as well as outputing the results straight into an infolog message");
    info(max(12, 12.001));
}


Another interesting point is that it can actually accept different types of arguments, for example, a real and an integer, as shown above. And it actually returns an anytype, which implicitly gets converted to a string when sent to the infolog.

Disclaimer: Since this is not a documented feature, it can theoretically change in the future releases, but I doubt it in this particular case.

Wednesday, July 07, 2010

Advertisement: MDCC is looking for talent!

Hello, all.

Microsoft Development Center in Copenhagen has a number of open positions for Software Development Engineers in Test (SDETs), to work in the team responsible for shipping the latest version of the Microsoft Dynamics AX product.

Below is a detailed description of one of the currently open positions (SDET II role). Salary level and title are based on your education, number of years of experience, etc., nothing new here. Dynamics AX background is, of course, a plus (I assume this applies to all my readers).
The Microsoft Dynamics AX product group has an open position for a Software Development Engineer in Test (SDET) within our supply chain management teams. The position provides unique opportunities for professionals with a diverse background of business acumen and software engineering to work on one of the fastest growing Enterprise Resource Planning (ERP) products in the market.

Responsibilities:
Write and review technical requirements and design documents
Plan, design, and write code for automated tests of features within the supply chain management features of Dynamics AX
Create and use test tools and processes to both increase effectiveness in the daily work and assure quality of the product
Collaborate with other engineers to ensure all feature areas achieve the desired high level of innovation and quality our customers demand.

Requirements:
We are looking for engineers with a strong background in object oriented development. Experience with business applications or ERP solutions are pluses.

Software development experience, particularly within C#, C++ or similar object oriented programming languages
Strong technical and analytical skills
Excellent problem solving and design skills
Ability to work independently - and in teams
An excellent command of written and spoken English
Experience with Microsoft Dynamics AX or ERP products is a plus
Experience with X++ (a Dynamics AX language) is a plus
Software testing experience with an organized and structured approach is also a plus

We are also looking for less experienced people for the IAESTE student program, so all you excellent Computer Science students, interested in developing business applications and working for one of the world's leading software companies, welcome!

If you are interested in applying for the positions, please e-mail me your up-to-date CV at ivan.kashperuk(@nospam)hotmail.com

An additional request I would like to make is to leave a comment here, if you are invited to an interview, describing how it went, how you were treated, and what your impression was of the entire process, the MDCC campus, the interviewers, etc. This will help us make improvements in our hiring process, so I am really waiting for your comments. Note that anonymous comments are allowed.

Some additional information about MDCC:
Microsoft Development Center Copenhagen (MDCC) was created in 2002 following the acquisition of the Danish company Navision. Today, it has grown to be Microsoft’s biggest development center in Europe and a spearhead in the European IT industry. MDCC is Microsoft’s Center of Excellence for Supply Chain Management and drives the development of several of the Microsoft Dynamics ERP (Enterprise Resource Planning) products. Our products enable companies throughout the world to optimize the planning of their resources – and increase their revenues.

Today, the development center gathers around 650 people from more than 40 different countries. Every third employee is a non-Dane and that makes MDCC to one of the most international companies in Denmark. MDCC has been widely awarded for its unique work culture and is a coveted career booster for top talents from all over the world.