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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Queries with multiple top level data sources cannot be applied to Forms.

(0) ShareShare
ReportReport
Posted on by 30

Hi,

In Release to Warehouse form, WHSInventTransSumDImSO is a datasource that pulls open sales orders which need to be released and displays them in the form.

Below change is needed only for sales orders and not for transfer orders.

I have added a new datasource to Release to Warehouse form. which has to go inner join with WHSInventTransSumDImSO and display only non-zero qty sales orders in Release to warehouse form.

TableView - WHSInventTransSumDimIssue is labeled as WHSInventTransSumDimSO in Form datasource.

I wrote a method in new datasource (WHSNonZeroQtyRelease) init  method to make a inner join.

Release to warehouse is not opening and I am getting the error message

Queries with multiple top level data sources cannot be applied to Forms.

Below is the code I tried

Extensionof(formDataSourceStr(WHSReleaseTowarehouse, WHSNonZeroQtyRelease))]

public void init()
{

next Init();

 FormDataSource WHSNonZeroQtyReleaseDB = this.formrun().dataSource(formDataSourceStr(WHSReleaseTowarehouse,WHSNonZeroQtyRelease));
 QueryBuildDataSource qbdsNonZeroQtyRelease = WHSNonZeroQtyReleaseDB.query().addDataSource(tableNum(WHSNonZeroQtyRelease));


QueryBuildDataSource qbdsWHSInventTransumDimIssue = qbdsNonZeroQtyRelease.addDataSource(tableNum(WHSINVENTTRANSSUMDIMISSUE));


qbdsWHSInventTransumDimIssue.joinMode(JoinMode::InnerJoin);

}

I have the same question (0)
  • Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Queries with multiple top level data sources cannot be applied to Forms.

    Let me post your code again, this time though Insert > Code (which is that you should use too):

    public void init()
    {
    	next init();
    
    	FormDataSource whsNonZeroQtyReleaseDB = this.formRun().dataSource(formDataSourceStr(WHSReleaseTowarehouse, WHSNonZeroQtyRelease));
    	QueryBuildDataSource qbdsNonZeroQtyRelease = whsNonZeroQtyReleaseDB.query().addDataSource(tableNum(WHSNonZeroQtyRelease));
    
    	QueryBuildDataSource qbdsWHSInventTransumDimIssue = qbdsNonZeroQtyRelease.addDataSource(tableNum(WHSINVENTTRANSSUMDIMISSUE));
    
    	qbdsWHSInventTransumDimIssue.joinMode(JoinMode::InnerJoin);
    }

    It seems that your code completely ignores WHSInventTransSumDimSO data source. Instead, you add two new data source, independent on any existing data source.

    If I understand your requirement correctly, you want to add a single data source (WHSNonZeroQtyRelease) as a child data source of WHSInventTransSumDimSO.

    Before writing any code, ask yourself if you can't simply add a new data source in a form extension.

    You'll need something like this:

  • Lakshmi Karambakkam Profile Picture
    1,307 on at
    RE: Queries with multiple top level data sources cannot be applied to Forms.

    Hi Martin,

    I already added this table as form datasource and I have to add few ranges so I have to extend the query.

    Could you guide me (through x++ code) how to call WHSInventTransSumDimSO data source  (rather than creating a new query.

  • Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Queries with multiple top level data sources cannot be applied to Forms.

    Then you should add no data source in code at all.

    If you want refer to WHSInventTransSumDimSO data source inside one of its (extended) method, simply use 'this'. If you want to get the related query data source, use this.queryBuildDataSource().

    To refer to it from other places in the same form, use whsInventTransSumDimSO_ds (whsInventTransSumDimSO_ds.queryBuildDataSource()). It's the name of the data source suffixed with _ds. There is also a variable of the same name as the data source, but it holds something else (the current table record).

  • Lakshmi Community Profile Picture
    30 on at
    RE: Queries with multiple top level data sources cannot be applied to Forms.

    Hi Martin,

    As you were proposing an approach without adding datasource, what are the steps to be taken to filter the data? Right now, Quantity available to release is a display field and user wants it as a regular field to filter and sort.

    What should be the best approach to do this task?

    Thanks

  • Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Queries with multiple top level data sources cannot be applied to Forms.

    Please create a new thread for this other topic and provide more details there. How it should be done depends on what code you have ine display method and how when the underlying data changes.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 724 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 580 Most Valuable Professional

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 554

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans