Code to set range in lookup for SSRS Report in Ax 2012

This is sample Code to set range in lookup for SSRS Report in Ax 2012 in UI Builder class.

First create lookup method in this sample code EmpLookUp is method for lookup then using post build and build method you can get lookup with range.


 public void build()  
 {  
   contract              = this.dataContractObject();  
   dialogReportNatureofSaration    = this.addDialogField(methodStr(TestSummaryContract, parmModeofSeparation),contract);  
   dialogreportEmpCode         = this.addDialogField(methodStr(TestSummaryContract, parmEmpId),contract);  
   dialogreportEmpCode.value("");  
   dialogReportNatureofSaration.value("");  
 }  
 private void EmpLookUp(FormStringControl EmpLookUp)  
 {  
   Query          query = new Query();  
   QueryBuildDataSource  queryBuildDataSource;  
   QueryBuildDataSource  queryBuildDataSourceLocal;  
   QueryBuildRange     queryBuildRange;  
   SysTableLookup     sysTableLookup;  
   ;  
   {  
     sysTableLookup=SysTableLookup::newParameters(tablenum(TestTransactions),EmpLookUp);  
     sysTableLookup.addLookupfield(fieldnum(TestTransactions,EmplId));  
     queryBuildDataSourceLocal = query.addDataSource(tableNum(TestTransactions));  
     queryBuildDataSourceLocal.addRange(fieldNum(TestTransactions, EosTransType)).value(SysQuery::value(dialogReportNatureofSaration.value()));  
     sysTableLookup.parmQuery(query);  
     sysTableLookup.performFormLookup();  
   }  
 }  
 public void getFromDialog()  
 {  
   contract = this.dataContractObject();  
   super();  
 }  
 public void postBuild()  
 {  
   super();  
   dialogReportNatureofSaration  = this.bindInfo().getDialogField(this.dataContractObject(),methodStr(TestSummaryContract, parmModeofSeparation));  
   dialogreportEmpCode       = this.bindInfo().getDialogField(this.dataContractObject(),methodStr(TestSummaryContract, parmEmpId));  
   dialogreportEmpCode.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(TestSummaryUIBuilder,EmpLookUp), this);  
   dialogreportEmpCode.lookupButton(2);  
 }