Hello Girish,
I've managed to add my dialog fields with the SysLookupMultiSelectCtrl. However I am unable to filter using the modified() override. See full code below:
class AMFSalesInvoiceReportUIBuilder extends SysOperationAutomaticUIBuilder
{
AMFSalesInvoiceReportContract contract;
DialogField dialogFldInventSite;
DialogField dialogFldFromDate;
DialogField dialogFldToDate;
DialogField dialogFldInvoiceAccount;
DialogField dialogFldCountryRegionId;
DialogField dialogFldStateId;
SysLookupMultiSelectGrid gridCountries;
SysLookupMultiSelectCtrl ctrlCountries;
SysLookupMultiSelectCtrl ctrlSites;
SysLookupMultiSelectCtrl ctrlInvoiceAccs;
SysLookupMultiSelectCtrl ctrlStateIds;
public void build()
{
contract = this.dataContractObject() as AMFSalesInvoiceReportContract;
dialogFldFromDate = this.addDialogField(methodStr(AMFSalesInvoiceReportContract, parmInvoiceFromDate), contract);
dialogFldToDate = this.addDialogField(methodStr(AMFSalesInvoiceReportContract, parmInvoiceToDate), contract);
dialogFldInventSite = this.addDialogField(methodStr(AMFSalesInvoiceReportContract, parmInventSiteId), contract);
dialogFldInvoiceAccount = this.addDialogField(methodStr(AMFSalesInvoiceReportContract, parmInvoiceAccount), contract);
dialogFldCountryRegionId = this.addDialogField(methodStr(AMFSalesInvoiceReportContract, parmCountryRegionId), contract);
dialogFldStateId = this.addDialogField(methodStr(AMFSalesInvoiceReportContract, parmStateId), contract);
dialogFldInventSite.lookupButton(2);
dialogFldInvoiceAccount.lookupButton(2);
dialogFldCountryRegionId.lookupButton(2);
dialogFldStateId.lookupButton(2);
}
//Overriding postRun and commenting out super() to prevent
//'RegisterOverrideMethod was called twice for the same object for method 'lookup'. You can only override a method once per instance.'
public void postRun()
{
//super();
dialog.dialogForm().formRun().controlMethodOverload(false);
dialogFldCountryRegionId.registerOverrideMethod(methodStr(FormStringControl, modified), methodStr(AMFSalesInvoiceReportUIBuilder, countryRegionModified), this);
this.lookupInventSiteId();
this.lookupInvoiceAccounts();
this.lookupCountryRegionIds();
this.lookupStateIds();
}
public void countryRegionModified(FormStringControl _control)
{
this.lookupStateIds();
}
public void lookupStateIds()
{
TableId multiSelectTableNum = tableNum(LogisticsAddressState);
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
container selectedFields;
container conCountryRegionIds;
int counter;
query = new Query();
qbds = query.addDataSource(tableNum(LogisticsAddressState));
qbds.addSelectionField(fieldNum(LogisticsAddressState, Name));
qbds.addSelectionField(fieldNum(LogisticsAddressState, CountryRegionId));
qbds.addSortField(fieldNum(LogisticsAddressState, Name));
qbds.addGroupByField(fieldNum(LogisticsAddressState, Name));
selectedFields = [multiSelectTableNum, fieldNum(LogisticsAddressState, Name)];
if (ctrlCountries)
{
conCountryRegionIds = ctrlCountries.getSelectedFieldValues();
//Loop over the container values and apply range to query
for(counter = 1; counter <= conLen(conCountryRegionIds); counter )
{
if (conPeek(conCountryRegionIds, counter) != '')
{
qbds.addRange(fieldNum(LogisticsAddressState, CountryRegionId)).value(queryValue(LogisticsAddressCountryRegion::findRecId(conPeek(conCountryRegionIds, counter)).CountryRegionId));
}
}
}
//If the container conCountryRegionIds, there will be a range to be applied
if (ctrlStateIds)
{
ctrlStateIds = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),
this.dialogFldStateId.control(), query,
false, selectedFields);
}
else
{
ctrlStateIds.refreshQuery(query);
}
}
public void lookupInvoiceAccounts()
{
TableId multiSelectTableNum = tableNum(CustTable);
Query query;
QueryBuildDataSource qbds;
container selectedFields;
query = new Query();
qbds = query.addDataSource(multiSelectTableNum);
qbds.addSelectionField(fieldNum(CustTable, InvoiceAccount));
selectedFields = [multiSelectTableNum, fieldNum(CustTable, InvoiceAccount)];
ctrlInvoiceAccs = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),
this.dialogFldInvoiceAccount.control(), query,
false, selectedFields);
}
///
/// Multi select lookup method for country region Ids
///
///
/// An object of _control class
///
public void lookupCountryRegionIds()
{
TableId multiSelectTableNum = tableNum(LogisticsAddressCountryRegion);
Query query;
QueryBuildDataSource qbds;
container selectedFields;
query = new Query();
qbds = query.addDataSource(multiSelectTableNum);
qbds.addSelectionField(fieldNum(LogisticsAddressCountryRegion, CountryRegionId));
qbds.addSortField(fieldNum(LogisticsAddressCountryRegion, CountryRegionId));
qbds.addGroupByField(fieldNum(LogisticsAddressCountryRegion, CountryRegionId));
selectedFields = [multiSelectTableNum, fieldNum(LogisticsAddressCountryRegion, CountryRegionId)];
ctrlCountries = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),
this.dialogFldCountryRegionId.control(), query,
false, selectedFields);
}
//to populate lookup
public void lookupInventSiteId()
{
TableId multiSelectTableNum = tableNum(InventSite);
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(multiSelectTableNum);
container selectedFields;
qbds.addSelectionField(fieldNum(InventSite, SiteId));
qbds.addSelectionField(fieldNum(InventSite, Name));
selectedFields = [multiSelectTableNum, fieldNum(InventSite, SiteId)];
ctrlSites = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().formRun(),
this.dialogFldInventSite.control(), query, false,
selectedFields);
}
}
When selecting the values in my country region IDs, it doesn't trigger the modified() method. Any ideas?