web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Cascade/Dependent Parameters error: Queries with multiple top level data sources cannot be applied to Forms.

(0) ShareShare
ReportReport
Posted on by

Hi All, 

I'm facing an issue: "Queries with multiple top level data sources cannot be applied to Forms", when create a lookup method for RetailStore and assign values to RetailStore parameter from District parameter. while the district is from logisticsPostalAddress Table. And the RetailStore parameter is from RetailTransaction Table. If I omit the peace of code :  qbds_District= query.addDataSource(tableNum(LogisticsPostalAddress));
then I'm facing the error: "QueryBuildDataSource object not initialized." I know very well the reason behind this error, but I want RetailStore parameter show the values according to the District Parmeter. 
This Is My LookUP code:

private void storeidlookup(FormStringControl storelookup)
{

Query query = new Query();
QueryBuildDataSource qbds_District, qbds_join;
SysTableLookup sysTableLookup;


sysTableLookup = SysTableLookup::newParameters(tableNum(RetailTransactionTable), storelookup);

qbds_District = query.addDataSource(tableNum(RetailTransactionTable));
qbds_District.addSortField(fieldnum(RetailTransactionTable, store));
qbds_District.addOrderByField(fieldnum(RetailTransactionTable, store));
qbds_District.orderMode(OrderMode::GroupBy);
SysTableLookup.parmUseLookupValue(false);
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield(fieldNum(RetailTransactionTable, store), true);
//qbds_District= query.addDataSource(tableNum(LogisticsPostalAddress));
query.dataSourceTable(tableNum(LogisticsPostalAddress)).addRange(fieldNum(LogisticsPostalAddress , state)).value(dialogRegion.value());


sysTableLookup.performFormLookup();
}


 Any help would be appreciate.

cheers,

Safdar Ali.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    You mustn't add the second datasource to the root of the query (query.addDataSource()), it obviously creates two top-level datasources, which doesn't make senses in lookups (that's what the message says).

    You want to join the second datatasource to the first one, which is done by qbds_District.addDataSource(...). Also don't forget to specify a relation.

  • Community Member Profile Picture
    on at

    Martin , there is no direct relation between these two datasources. Its means i must join the other dataSources as well ? like retailChannelTable and DirpartyLocation

  • Verified answer
    Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    If there is no logical relation, then your join doesn't make sense and you have to fix the bug in your design. Maybe you need another table.

    If there is a logical relation but not a physical one, simply add a link between right fields.

  • Community Member Profile Picture
    on at

    OK thanks Martin

  • Community Member Profile Picture
    on at

    Martin , one more thing if I'm not going to write lookup method for RetailStore because without writing a lookup method its drop down working fine, my problem is that i want to filter RetailStore according to District values , is there any other method where i just passing values from District to RetailStores

  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    I'm sorry, but I don't know the context.

    If it's not related to "Queries with multiple top level data sources", could you please create a new thread and explain your question in detail there?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans