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.

https://erpdax.wordpress.com/2014/07/11/10/

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

1

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 getFromDialog, initializeFields
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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s