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 :
Finance | Project Operations, Human Resources, ...
Answered

Join Data Sources on a form

(0) ShareShare
ReportReport
Posted on by

I have a grid on a form that has custInvoiceTrans  as a data source.  I  want to add the sales line.  

Here's the problem:

If I add the sales line to the form through the UI, it does not link it correctly:

pastedimage1657591119607v1.png

But if I link on the init method of CustInvoiceTrans, then I do not seem to have the option of adding sales line fields to the Grid (based to CustInvoiceTrans)

Thank you

I have the same question (0)
  • Alex VN Profile Picture
    1,994 on at

    Hi,

    May I know when you add SalesLine link to the init method of CustInvoiceTrans, do you also add that datasource with join on form design?

    If you want to add salesline to the grid, you might add it in form design first, then use code to get that DS and link to CustInvoiceTrans and then you can drag the field from Salesline ds to the grid.

    Regards,

  • brianmaric Profile Picture
    on at

    I tried adding it to the form data source and set the link on the init method of CustInvoiceTrans.  I get an error if I set join source and it does not see the table if I do not set join source.

    I could add the sales line first, but I need fields from both tables on the Grid.

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

    It's difficult to help you if you tell us mere "I get an error". Please show us your code and tell us which error you got and where.

  • brianmaric Profile Picture
    on at

    Here's the set up:

    pastedimage1657643413998v1.png

    pastedimage1657643443735v2.png

    Here's the code:

     [DataSource]
        class SalesLine
        {
            /// 
            ///
            /// 
            public void init()
            {
       
                QueryBuildDataSource qbds;
                QueryBuildDataSource qbds_SalesLine,qbds_CustInvoiceTrans;
    
                super();
    
                qbds_SalesLine = SalesTable_ds.query().dataSourceTable(tableNum(SalesLine));
                qbds_CustInvoiceTrans = qbds_SalesLine.addDataSource(tableNum(CustInvoiceTrans));
                qbds_CustInvoiceTrans.addLink(fieldNum(SalesLine,InventTransId),fieldNum(CustInvoiceTrans,InventTransId));
                qbds_CustInvoiceTrans.joinMode(JoinMode::InnerJoin);
    
    
            }
    
        }

    Here's the result:

    pastedimage1657643853627v4.png

    It's only pulling the first invoice ID

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

    You have a CustInvoiceTrans data source in the form, but your code doesn't add a relation to it. Your code adds an additional data source to the query, which has nothing to do with the form data source. Therefore your code has no impact on CustInvoiceTrans data source.

    If you want to work with the query used by CustInvoiceTrans data source, refer to it by CustInvoiceTrans_ds.queryBuildDataSource(). Don't create a second data source for CustInvoiceTrans.

  • brianmaric Profile Picture
    on at

    Ok Thanks, but do I need to add the SalesLine  to the CustInvoiceTrans data Source like this:

    pastedimage1657645612917v1.png

    If i do, then it add a relation (the wrong one)

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

    Yes, configure JoinSource and LinkType in data source properties.

    Use clearLinks() (of the QueryBuildDataSource object for CustInvoiceTrans data source) to remove existing links and then use addLink() (as you do in your code).

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans