AX 2012: Multi-Select Lookup for SSRS Report Dialog
AX 2012: Multi-Select Lookup for SSRS Report Dialog
Overview:
In 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):
- build() method overridden to add dialog field.
- postBuild() method overridden to register custom lookup method with lookup event.
- custTableLookup() method gives custom lookup implementation.
- postRun() method overridden to comment out super() method call.
- super() is commented to avoid the following exception:
- RegisterOverrideMethod was called twice for the same object for method ‘lookup’…
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):
- showPrintSettings() method overridden to return false to turn off Print Settings field group.
- showQueryValues() method overridden to return false to turn off default query parameters fields.
- main() method runs the report.
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):
- processReport() method adds multiple ranges to the query for multiple customers selected in lookup
[ 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; QueryBuildDataSource qbdsCustTable; ListIterator custListIterator; contract = this.parmDataContract() as MAKParametersContract; custListIterator = new ListIterator(contract.parmCustAccountList()); query = new Query(queryStr(MAKCustTable)); qbdsCustTable = query.dataSourceTable(tableNum(CustTable)); while(custListIterator.more()) { qbdsCustTable.addRange( fieldNum(CustTable, AccountNum)).value(custListIterator.value()); custListIterator.next(); } 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
Comments
Post a Comment