I have two multiselect fields in a form. I want to populate second field based on the selected value of first field. In form init method, I have initialized the mutiselect fields. And On modified method of first field I am calling msCtrlDealerGroup.refreshQueryRun(element.dealerGroupQuery()); but its not refershing the grid.
Note: I am following the last post in the thread of this blog: http://dynamicsuser.net/forums/p/79568/441037.aspx
Anyone please help.
Thanks,
Samiya
*This post is locked for comments
Hi Potturi,
Thanks for your post, It works for me :-)
// Vasanth Arivali
ok i got it. That suprises me as well. If we create a new new Query Run and apply ranges the control is not getting filtered but we get the query from old QueryRun Object and apply ranges then refresh works .. Interesting. Thanks
Hi,
Try this code in form init method.
Query QueryRevenue, QueryRevenueSub;
QueryBuildRange qbrQueryRevenue, qbrQueryTagCategroy;
QueryBuildDataSource qbdFinancialTag, qbdFinancialTagSub;
DimensionAttribute DimAttrRevenue, DimAttrSubRev;
DimensionAttributeDirCategory DimAttrDirRevenue, DimAttrDirRevenueSub;
DimensionAttribute dimensionRevenue, dimensionRevenuesub;
QueryRevenue = new Query();
// filtered Revenue related dimension values
select * from dimensionRevenue where dimensionRevenue.Name == CustParameters::find().RevenueGroup;
select RecId from DimAttrRevenue where DimAttrRevenue.Name == dimensionRevenue.Name;
select DirCategory from DimAttrDirRevenue where DimAttrDirRevenue.DimensionAttribute == DimAttrRevenue.RecId;
qbdFinancialTag = QueryRevenue.addDataSource(TableNum(DimensionFinancialTag));
qbrQueryRevenue = qbdFinancialTag.addRange(FieldNum(DimensionFinancialTag, FinancialTagCategory));
qbrQueryRevenue.value(strFmt('%1',DimAttrDirRevenue.DirCategory));
qbdFinancialTag.fields().addField(fieldNum(DimensionFinancialTag,Value));
qbdFinancialTag.fields().addField(fieldNum(DimensionFinancialTag,Description));
super();
MultiselectRevenue = sysLookupMultiselectCtrl::constructWithQuery(element,RevenueGroup,QueryRevenue );
Regards,
Edwin
Ok it works. My problem was the new initialization of the queryRun!
Thanks
Were you able to refresh the second multi select field based on the selection from the first multi Select ? The RefreshQueryRun needs the same Old QueryRun that was used during initialization of the control. If we update the range of the QueryRun Query (as i mentioned above) and pass the QueryRun to the RefreshQueryRun , it works.
Why are we again doing a look up externally ?
The problem is (as described in the title) that the "refreshQueryRun" does not work.
I've seen that the refreshQueryRun refresh only the queryRun and not the query, that is used in the method ctrlNames_lookup (of the class
SysLookupMultiSelectGrid):
SysLookupMultiSelectGrid::lookup(query, fsCtrlIds, fsCtrlNamesTmp, selectField, queryRun);
Hi,
Please follow these steps to fix the problem if you had not already fixed this. The multi select drop down selection should filter the second multi select drop down.
i took an example of inventsite and inventlocation as example
In the class declaration of the form , have the necessary declarations for multiselectCtrl along with the QueryRun objects
public class FormRun extends ObjectRun
{
SysLookupMultiSelectCtrl siteCtrl,locationCtrl;
QueryRun locationQueryRun;
Query q;
QueryBuildDataSource qbd;
}
// In the init function of the form instantiate the two controls respectively. the
msCtrlLocation , SiteCtrl are the two StringEdit Controls on the form with autoDeclaration to Yes
q = new Query();
qbd = q.addDataSource(TableNum(InventLocation));
qbd.addRange(FieldNum(InventLocation, InventSiteId));
locationQueryRun = new QueryRun(q);
super();
locationCtrl = SysLookupMultiSelectCtrl::constructWithQueryRun(element, msCtrlLocation, locationQueryRun);
siteCtrl = SysLookupMultiSelectCtrl::construct(element, SiteCtrl, queryStr(InventSiteQry));
In the modified function of Site Control which is siteCtrl
boolean ret;
int i;
str siteID;
ret = super();
// Assign the selected site values into string siteid (which is a comma seperated site ids..)
if (ret)
{
// siteContainer = ; // get actual value of the selected rows
siteID = con2Str(siteCtrl.getSelectedFieldValues());
}
// Get the Query from the same QueryRun that was used in the init function on the form, if we use a seperate one it wont work.
In our case it is locationQueryRun
q = locationQueryRun.query() ;
qbd = q.dataSourceTable(tableNum(InventLocation));
qbd.clearRange(fieldNum(InventLocation, InventSiteId));
// Pass the comma Seperated SiteID to addRange
qbd.addRange(fieldNum(InventLocation, InventSiteId)).value(siteID);
// RefreshQueryRun with the modified QueryRun
locationCtrl.refreshQueryRun(locationQueryRun);
The second multi Select list will be filtered based on the selection
Hope this helps
Thanks
Hi,
Please follow these steps to fix the problem if you had not already fixed this. The multi select drop down selection should filter the second multi select drop down.
i took an example of inventsite and inventlocation as example
In the class declaration of the form , have the necessary declarations for multiselectCtrl along with the QueryRun objects
public class FormRun extends ObjectRun
{
SysLookupMultiSelectCtrl siteCtrl,locationCtrl;
QueryRun locationQueryRun;
Query q;
QueryBuildDataSource qbd;
}
// In the init function of the form instantiate the two controls respectively. the
msCtrlLocation , SiteCtrl are the two StringEdit Controls on the form with autoDeclaration to Yes
q = new Query();
qbd = q.addDataSource(TableNum(InventLocation));
qbd.addRange(FieldNum(InventLocation, InventSiteId));
locationQueryRun = new QueryRun(q);
super();
locationCtrl = SysLookupMultiSelectCtrl::constructWithQueryRun(element, msCtrlLocation, locationQueryRun);
siteCtrl = SysLookupMultiSelectCtrl::construct(element, SiteCtrl, queryStr(InventSiteQry));
In the modified function of Site Control which is siteCtrl
boolean ret;
int i;
str siteID;
ret = super();
// Assign the selected site values into string siteid (which is a comma seperated site ids..)
if (ret)
{
// siteContainer = ; // get actual value of the selected rows
siteID = con2Str(siteCtrl.getSelectedFieldValues());
}
// Get the Query from the same QueryRun that was used in the init function on the form, if we use a seperate one it wont work.
In our case it is locationQueryRun
q = locationQueryRun.query() ;
qbd = q.dataSourceTable(tableNum(InventLocation));
qbd.clearRange(fieldNum(InventLocation, InventSiteId));
// Pass the comma Seperated SiteID to addRange
qbd.addRange(fieldNum(InventLocation, InventSiteId)).value(siteID);
// RefreshQueryRun with the modified QueryRun
locationCtrl.refreshQueryRun(locationQueryRun);
The second multi Select list will be filtered based on the selection
Hope this helps
Thanks
The problem is that the refreshQueryRun is called on the SysLookupMultiSelectCtrl and not on the SysTableLookup.
try overriding the lookup field on the second dropdown and pass the first field value as a range
public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
SysTableLookup sysTableLookup;
QueryBuildDataSource queryBuildDataSource;
;
sysTableLookup = SysTableLookup::newParameters(tablenum(tblName), _formControl);
sysTableLookup.addLookupfield(fieldnum(fieldid1, fieldid2)) ;
queryBuildDataSource = query.addDataSource(tablenum(tblName));
queryBuildDataSource.addRange(fieldNum(tblName,filterParentFieldId).value(ParentTable.FieldID);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,900 Super User 2024 Season 2
Martin Dráb 229,297 Most Valuable Professional
nmaenpaa 101,156