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;
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…
Finally, from the DP class we can simply instantiate the contract and get the value…