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

by Patrik Luca 0 comments

Tag



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)

        {

            ctrlActiveAll.selection(ProjActiveAll::All);

        }

    }

  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.




Comments 0 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

Subscribe feeds rss Recent Entries

Categories

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

Followers

Links