Passing Arguments to a Data Provider Class in Dynamics AX

By Laura Lake | July 10, 2015

Many Dynamics AX reports utilize Data Provider classes, so when modifying existing reports or creating new ones, there is often a need to pass information to the DP class from the report controller class. Here is a simple example of how this can be done.

In this example, the customer has two menu items on a form calling the same report, and the report needs the information about which menu item the user selected.

First we need a new parm method on the data contract so that we can set the value from the controller class and later retrieve it in the DP class.

public UserMenuSelection parmOutputSelection(str _outputSelection = outputSelection)
{
    outputSelection = _outputSelection;
    return outputSelection;
}

The DataMemberAttribute attribute identifies our parm method as a member of the data contract.
As is usually the case, the report controller class is called from the Output Menu Item and since Args is passed to the Main() method we can utilize Args().MenuItemName to retrieve the user’s selection as in the screen shot below…

Classes PSA Purchase Order Controller

Finally, from the DP class we can simply instantiate the contract and get the value…

Classes Purchase Order DP

Related Posts


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!