My 2p about ERP Solutions, Information Worker Solutions and other software products (mainly Microsoft Dynamics AX and Microsoft SharePoint).

29 June 2010

Opening same form but with different behaviour

Business requirement: Change the behaviour of a form without user interaction

Upon opening a form, you would like to change its behaviour without interaction of the end user, for example, you want to preset some filters, hide some columns, … depending on the context it is called. Off course you want to avoid to create a second, third, … form for this requirement.

This post describes how this can be achived easily by merely creating a new Menu Item and adding a little piece of code in the form involved.

As example in this post the Project Item Requirements form will be opened with a different filter. Depending on the context, all item requirements will be shown or only the active requirements.

Solution: Use the EnumTypeParameter property on a Menu Item

  1. Drag and drop the ProjSalesItemReq form to the Display node in the AOT as such creating a new Display Menu Item.
  2. Set the EnumTypeParameter property of the newly created Menu Item to NoYes and the EnumParameter property to Yes.
  3. Add a variable to the init method of the form ProjSalesItemReq, which will be used to store the value according to with which menu item the ProjSalesItemReq form will be called.
    NoYes                   showAll;

  4. Add following code snippet to the init method of the form ProjSalesItemReq, to set the value of the filter if the form is called with the newly created Menu Item.

    if (element.args().parmEnumType())


        showAll = element.args().parmEnum();

        if (showAll)





  5. Add the newly created Menu Item to the ProjTable form.

If you open the Item Requirements form with the standard Dynamics AX MenuItemButton, the filter will be set to Active, showing only the active item requirements.

If you open the Item Requirements form with the newly created MenuItemButton, the filter will be set to All, showing all item requirements for the selected Project.

Continue reading......

by Patrik Luca 0 comments

25 June 2010

X++ Code Snippet: Using a Message Box

This X++ Code Snippet post describes the use of a Message Box to ask the user for a confirmation before an update or process is executed.

X++ Code Snippet: Using a Message Box

A Message Box will be created using the Box class, asking the end user for a confirmation before the process is executed. Create following job to understand the working of the Message Box. This job will do an update of the CustTable each time the end user presses the OK button in the Message Box, else the CustTable isn’t updated.

static void tutorial_box() 

    CustTable   custTable;

    if(Box::yesNo("Modify customer?"

                  , DialogButton::No)

        == DialogButton::No)


    select forUpdate custTable

    where custTable.AccountNum  == "1101";

    custTable.Memo += "\r\n"
                   + date2str(SystemDateGet(),123,2,1,2,1,4)

+ " "

                   + time2str(timenow(), 1, 1);


Each time you run the Job a Message Box appears:

If the end user chooses Yes, the Memo field of the CustTable will be update, else not.

Continue reading......

by Patrik Luca 0 comments

15 June 2010

Export to Excel with X++ code: continued


I wrote already in the past about the possibilities to export data from your Dynamics AX ERP system to Microsoft Excel through X++ code.

My first post Export to Excel with X++ code described how to export some data to different worksheets in an Excel file.

My second post Export to Excel with X++ code: the sequel described how to format the exported data in the Excel export file.

In this post I further elaborate about the formatting of data.

Use of the comObject method of the SysExcelStyle class

I already explained the use of the SysExcelStyle class in my previous posts. I created a Header style and set its font to bold and a specific color. These methods are easy to use, as they can found with the IntelliSense functionality.

However, by using the comObject method, you can go even further and have extra formatting possibilities at your disposal. Unfortunately, these can’t be found with IntelliSense, nor I find documentation about it. I found already these possibilities, if someone finds other ones, please post a comment: it could be handy for others aswell…

SysExcelStyle style;

// Set orientation
// distribute text
// center text
// right align text
// set indent level
// wrap text

Continue reading......

by Patrik Luca 2 comments

Patrik Luca, Ieper, BELGIUM
Feel free to use or spread all of the content on my blog. In return, linking back to my blog would be greatly appreciated. All my posts and articles are provided "AS IS" with no warranties.

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Most Read Entries


Recommended Books

Subscribe feeds rss Recent Comments

This Blog is part of the U Comment I Follow movement in blogosphere. Means the comment field of this blog is made DOFOLLOW. Spam wont be tolerated.

Blog Archive

My Blog List