Thursday 27 February 2020

Failed to execute query because no root data source on the form matches the root datasource on the query.

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.

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...