Contact Me

Total Pageviews

Friday 4 July 2014

Creating multi-select lookup dialog for SSRS report parameter in MS Dynamics AX 2012

Hello All,
I just recently found a way to create a multi select lookup
dialog for SSRS report parameter using SysLookupMultiSelectGrid
class. I thought it might be helpfull for other developers
as well since I couldn't find any other Blog or Post answering this issue.

I am just assuming that you know how to create a simple dialog
for reporting parameter. However, if you don't know this link might be helpfull to you.http://www.artofcreation.be/2011/08/22/ax2012-sysoperation-part-1-data-contracts-and-service-operations/

I will just write those methods which will create a multi select
dialog. So, here we go.

Step 1:
In your data contract class declaration method, define your
parameter with 'List'. For example I want to create a multi select dialog for
customers in which I need Customer account to be selected when a user selects
any customer. SO, I will write

List accountNum;
In your DataMemberAttribue method type
the following code

[
DataMemberAttribute('AccuontNum'),
AifCollectionTypeAttribute('AccountNum', Types::String),
SysOperationLabelAttribute(literalstr("@SYS302"))
]
public List parmAccountNum(List _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
Your screen will look like this

Step 2:
Now that you have completed the contract class, let’s move on to
the UI Builder class. In your main lookup method write the following code.

public void
lookup(FormStringControl _control)
{
Query query = new Query(queryStr(CustTableSRS));
container cnt;
SysLookupMultiSelectGrid::lookup(query, _control, _control, cnt);
}
you may have to create 3 more methods to run your code without any
error. They are getFromDialoginitializeFields
and postRun. Here is the code for these methods. you have to change the contract class name with your
contract class

First create a new mothod for initializeFields and paste the following code
public void
initializeFields()
{
custMultiSelectContract contract = this.dataContractObject();
}
Then create another method for getFromDialog
public void getFromDialog()
{
custMultiSelectContract contract = this.dataContractObject();
super();
}
and then another method for postRun
public void postRun()
{
custMultiSelectContract contract = this.dataContractObject();
}
That's it. You are now done. Run your report and enjoy.
Thanks.
Happy Daxing:)

No comments:

Post a Comment