AX 2012: Multi-Select Lookup for SSRS Report Dialog
Hi all,
n this post we’ll learn how to build multi-select lookup for SSRS report dialog. We’ll create an RDP report with an AutoDesign layout. Controller will be used to run the report. An output menu item will be created to point to the controller class. Each AOT element involved will be described in detail. You can guess the complexity of this development task by looking at the AOT elements required for it:
Let’s develop them piece by piece…
1. MAKCustTable (Query):
1. Create MAKCustTable query.
2. Drag CustTable table to the data sources node.
3. Select the fields as shown in the picture.
2. Drag CustTable table to the data sources node.
3. Select the fields as shown in the picture.
2. TmpMAKParameters (InMemory Table):
1. Create InMemory table TmpMAKParameters.
2. Add the fields in the table as shown in the picture.
2. Add the fields in the table as shown in the picture.
3. MAKParametersUIBuilder (UI Builder Class):
class MAKParametersUIBuilder extends SysOperationAutomaticUIBuilder { DialogField dialogCust; } public void build() { MAKParametersContract contract; contract = this.dataContractObject() as MAKParametersContract; dialogCust = this.addDialogField( methodStr(MAKParametersContract, parmCustAccountList), contract); } public void postBuild() { MAKParametersContract contract; super(); contract = this.dataContractObject() as MAKParametersContract; dialogCust = this.bindInfo().getDialogField( contract, methodStr(MAKParametersContract, parmCustAccountList)); dialogCust.registerOverrideMethod( methodStr(FormStringControl, lookup), methodStr(MAKParametersUIBuilder, custTableLookup), this); if (dialogCust) { dialogCust.lookupButton(2); } } private void custTableLookup(FormStringControl _control) { Query query; container conCustTable; query = new Query(queryStr(MAKCustTable)); SysLookupMultiSelectGrid::lookup( query, _control, _control, conCustTable); } public void postRun() { //super(); }
4. MAKParametersContract (Contract Class):
[ DataContractAttribute, SysOperationContractProcessingAttribute(classstr(MAKParametersUIBuilder)) ] class MAKParametersContract { List custAccountList; } [ DataMemberAttribute("custAccountList"), AifCollectionTypeAttribute("custAccountList", Types::String), SysOperationLabelAttribute(literalStr("Customers")) ] public List parmCustAccountList(List _custAccountList = custAccountList) { custAccountList = _custAccountList; return custAccountList; }
5. MAKParametersController (Controller Class):
class MAKParametersController extends SrsReportRunController { } public boolean showPrintSettings() { return false; } public boolean showQueryValues(str parameterName) { return false; } public static void main(Args _args) { MAKParametersController controller; controller = new MAKParametersController(); controller.parmReportName(ssrsReportStr(MAKParametersReport, AutoDesign)); controller.parmArgs(_args); controller.startOperation(); }
6. MAKParametersDP (Data Provider Class):
[ SRSReportParameterAttribute(classStr(MAKParametersContract)) ] class MAKParametersDP extends SRSReportDataProviderBase { MAKParametersContract contract; TmpMAKParameters tmpMAKParameters; } [ SRSReportDataSetAttribute("TmpMAKParameters") ] public TmpMAKParameters getTmpMAKParameters() { select * from tmpMAKParameters; return tmpMAKParameters; } public void populateTmpTable(AccountNum _accountNum) { CustTable custTable; while select custTable where custTable.AccountNum == _accountNum { tmpMAKParameters.AccountNum = custTable.AccountNum; tmpMAKParameters.CustGroup = custTable.CustGroup; tmpMAKParameters.insert(); } } [SysEntryPointAttribute] public void processReport() { Query query; QueryRun queryRun; CustTable custTable; contract = this.parmDataContract() as MAKParametersContract; query = new Query(queryStr(MAKCustTable)); //query.dataSourceTable(tableNum(CustTable)).addRange(fieldNum(CustTable, AccountNum)).value(SysQuery::value(contract.parmAccountNum())); queryRun = new QueryRun(query); while(queryRun.next()) { custTable = queryRun.get(tableNum(custTable)); this.populateTmpTable(custTable.AccountNum); } }
7. MAKParametersReport (SSRS Report):
1. Create MAKParametersReport SSRS Report.
2. Create a new RDP dataset.
3. Select MAKParametersDP
4. Drag the dataset to the Designs node.
5. Save, build and deploy the report.
2. Create a new RDP dataset.
3. Select MAKParametersDP
4. Drag the dataset to the Designs node.
5. Save, build and deploy the report.
8. MAKParametersReport (Output Menu Item):
1. Create an output menu item MAKParametersReport.
2. Set ObjectType to Class.
3. Set Object to MAKParametersController
2. Set ObjectType to Class.
3. Set Object to MAKParametersController
We are now good to run the report by clicking the menu item :)
No comments:
Post a Comment