AX 2012 D365 FORM LOOKUP ERROR
It might be the case that you get the below error.
Failed to execute query because no root data source on the form matches the root datasource on the query.
In order to fix it make sure that the datasource used should be the same as defined .
For example.
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tableNum(InventSite));
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(VendTable), _formControl);
sysTableLookup.addLookupfield(fieldNum(InventSite, SiteId));
sysTableLookup.addLookupfield(fieldNum(InventSite, Name));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
In the above site lookup code you will get the same error because VendTable was used in the parameter instead of the inventsite so to fix , it should be defined as below.
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tableNum(InventSite));
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(InventSite), _formControl);
sysTableLookup.addLookupfield(fieldNum(InventSite, SiteId));
sysTableLookup.addLookupfield(fieldNum(InventSite, Name));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
thanks,
Vikas Mehta.
It might be the case that you get the below error.
Failed to execute query because no root data source on the form matches the root datasource on the query.
In order to fix it make sure that the datasource used should be the same as defined .
For example.
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tableNum(InventSite));
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(VendTable), _formControl);
sysTableLookup.addLookupfield(fieldNum(InventSite, SiteId));
sysTableLookup.addLookupfield(fieldNum(InventSite, Name));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
In the above site lookup code you will get the same error because VendTable was used in the parameter instead of the inventsite so to fix , it should be defined as below.
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tableNum(InventSite));
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(InventSite), _formControl);
sysTableLookup.addLookupfield(fieldNum(InventSite, SiteId));
sysTableLookup.addLookupfield(fieldNum(InventSite, Name));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
thanks,
Vikas Mehta.
Hi Vikas,
ReplyDeleteMy Doubt is when there is a multiple DataSources are there what we will write in the NewParameters and also one more Doubt, when I am writing in the FormControlEventHandler onLookUp method I want to add another Form DataSource to my Form DataSource in Dynamice Query..