Today we see how to get multi-select lookup in the report dialog. This is used to sys operation Framework also. We have to fetch selected records in dp class or service class. For this, I wrote logic in the below classes.
Contract Class :
[
DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(UIBuilderClass))
]
class ContractClass
{
List vendAccountList;
[
DataMemberAttribute("Vendor"),
AifCollectionTypeAttribute("Vendor", Types::String),
SysOperationLabelAttribute(literalstr("Vend account")),
SysOperationHelpTextAttribute(literalstr("Vend account.")),
SysOperationDisplayOrderAttribute('1')
]
public List parmVendorList(List _vendAccountList = vendAccountList)
{
vendAccountList = _vendAccountList;
return vendAccountList;
}
}
_________________________________________________________________________________
UI Builder Class:
class UIBuilderClass extends SrsReportDataContractUIBuilder
{
ContractClass myContractClass;
DialogField
dialogField;
container con;
public void build()
{
myContractClass = this.dataContractObject() as ContractClass;
dialogField = this.addDialogField(methodStr(ContractClass, parmVendorList),
ContractClass);
}
public void postBuild() //or postRun() we can use any method.
{
super();
myContractClass = this.dataContractObject() as ContractClass;
dialogField = this.bindInfo().getDialogField(ContractClass,
methodStr(ContractClass, parmVendorList));
dialogField.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(UIBuilderClass, VendorLookup), this);
methodStr(UIBuilderClass, Vendormodified), this); // modified method.
}
public void VendorLookup(FormStringControl _control)
{
Query query = new Query();
QueryBuildDataSource vendQBD;
vendQBD = query.addDataSource(tableNum(VendTable));
vendQBD.addSelectionField(fieldNum(VendTable, AccountNum));
SysLookupMultiSelectGrid::lookup(query,
_control,
_control,
_control,
con);
}
}
__________________________________________________________________________________
DP Class:
[
SRSReportQueryAttribute (querystr(Myquery)),
SRSReportParameterAttribute(classstr(ContractClass))
]
class DPClass extends SRSReportDataProviderBase //SrsReportDataProviderPreProcess
{
MyTable myTable;
List vendorList;
Vendtable vendTable;
[SRSReportDataSetAttribute(tableStr('MyTable'))]
public MyTable getTempMyTable()
{
select MyTable;
return MyTable;
}
private Query buildQuery(Query
_query,List _vendorList)
{
ListIterator listIterator = new ListIterator(_vendorList);
while(listIterator.more())
{
_query.dataSourceTable(tablenum(VendTable)).addRange(fieldnum(VendTable, AccountNum)).value(queryValue(listIterator.value()));
listIterator.next();
}
return _query;
}
public void processReport()
{
QueryRun queryRun;
TestContractClass contract = this.parmDataContract() as TestContractClass;
Query query = this.parmQuery();
;
vendorList = contract.parmVendorList();
queryRun = new QueryRun(vendorList.empty() ? query : this.buildQuery(this.parmQuery(), vendorList));
while(queryRun.next())
{
vendTable = queryRun.get(tablenum(VendTable));
this.insertIntoTempTable();
}
}
private void insertIntoTempTable()
{
myTable.AccountNum = vendTable.AccountNum;
myTable.VendGroup = vendTable.VendGroup;
myTable.insert();
}
}