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 of all you have to 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(); }
No create Controller Class for run the report
Controller Class:-
class SampleController extends SrsReportRunController { SampleContract Contract; } protected void prePromptModifyContract() { super(); //if (this.parmArgs() && this.parmArgs().record()) //{ Contract = this.parmReportContract().parmRdpContract() as SampleContract; Contract.ParmItemId(); //} } public boolean showPrintSettings() { return false; } public boolean showQueryValues(str parameterName) { return false; } public static void main(Args _args) { SampleController controller; controller = new SampleController(); controller.parmReportName(ssrsReportStr(SSRSReportName, SSRSReportDesignName)); controller.parmArgs(_args); controller.startOperation(); }
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.
Thanks for comments.....