Multi Select Lookup in SSRS Report in D365
Multi Select Lookup
in SSRS Report in D365
Description:- Here we will create multi select lookup in ssrs report so we can
select multiple data from lookup. Here I have given sample demonstration for
how to generate multi select lookup in ssrs report.
First,
you must create contract class for that and create method for parameters.
Contract
Class: -
[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(SampleUIBuilder))]
class SampleContract implements SysOperationValidatable
{
List ListItemId;
[DataMemberAttribute("Item
Id"),AifCollectionTypeAttribute("Item Id", Types::String),
SysOperationLabelAttribute(literalStr("Item Id"))]
public List parmItemId(List _ListItemId = ListItemId)
{
ListItemId
= _ListItemId;
return ListItemId;
}
}
//For validation parameters,
public boolean validate()
{
boolean isValid = true;
List ItemIdList = new List(Types::String);
ItemIdList = this.parmItemId();
if(!ItemIdList.elements())
{
isValid = checkFailed("ItemId should not be empty");
}
return isValid;
}
Now
Create AOT Query like below.
No
create UI Builder class and give meaningful name for that
UI Builder Class:-
class SampleUIBuilder extends SysOperationAutomaticUIBuilder
{
DialogField dialogItemId
SampleContract SampleContract;
}
private void ItemIdLookup(FormStringControl _control)
{
Query query;
container conItemId;
query = new Query(queryStr(ItemListQuery));
SysLookupMultiSelectGrid::lookup(query,_control,_control,conItemId);
}
public void build()
{
int i;
SampleContract contract;
contract = this.dataContractObject() as SampleContract;
dialogItemId = this.addDialogField(methodStr(SampleContract,
parmItemId),contract);
}
public void postBuild()
{
SampleContract contract;
super();
contract = this.dataContractObject() as SampleContract;
dialogItemId = this.bindInfo().getDialogField(contract,methodStr(SampleContract,
parmItemId));
dialogItemId.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(SampleUIBuilder, ItemIdLookup),this);
if (dialogItemId)
{
dialogItemId.lookupButton(2);
}
}
public void postRun()
{
//super();
}
Now
Create Data Procedure class to run you login and get data from procedure.
Data
Provider Class:-
[SRSReportParameterAttribute(classStr(SampleContract))]
class SampleDp extends SRSReportDataProviderBase
{
SampleContract contract;
MyTable MyTable;
}
[SRSReportDataSetAttribute("MyTable")]
public MyTable get MyTable ()
{
select * from MyTable;
return MyTable;
}
[SysEntryPointAttribute]
public void processReport()
{
List list = new List(Types::String);
Query
queryItemId;
QueryRun
queryRunItemId;
InventItemGroupItem InventItemGroupItem;
QueryBuildDataSource qbdsItemId;
ListIterator
ItemIdListIterator;
contract = this.parmDataContract() as SampleContract;
list = contract.parmItemId();
if(list != null)
{
ItemIdListIterator = new ListIterator(list1);
queryItemId = new Query(queryStr(ItemListQuery));
qbdsItemId =
queryItemId.dataSourceTable(tableNum(InventItemGroupItem));
while(ItemIdListIterator.more())
{
qbdsItemId.addRange(
fieldNum(InventItemGroupItem, ItemId)).value(ItemIdListIterator.value());
ItemIdListIterator.next();
}
queryRunItemId = new QueryRun(queryItemId);
while(queryRunItemId.next())
{
InventItemGroupItem =
queryRunItemId.get(tableNum(InventItemGroupItem));
Info(strfmt("ItemId - %1",
InventItemGroupItem.ItemId));
}
}
}
Now
in Visual Studio add the following
1. Add
Report
2. Add
Data Set
1. Set the Properties for
that Data Set.
3. Set
the Parameters you want to set blank value for ItemId Parameters
1. Allow
blank = true
2. Nullable
= true
4. Add
Precision Design
5. Deployed
SSRS Report and Run it.
Comments
Post a Comment