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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Is it possible to return related data in each row?

(0) ShareShare
ReportReport
Posted on by

I have the following query (part of it)

dataSourceDPL = dataSourceFE.addDataSource(tableNum(DirPartyLocation), "DirPartyLocation");
    dataSourceDPL.addLink(fieldNum(FiscalEstablishment_BR, DirPartyLocation), fieldNum(DirPartyLocation, RecId));
    dataSourceDPL.fetchMode(QueryFetchMode::One2One);
    dataSourceDPL.joinMode(JoinMode::InnerJoin);

    dataSourceDPT = dataSourceDPL.addDataSource(tableNum(DirPartyTable), "DirPartyTable");
    dataSourceDPT.addLink(fieldNum(DirPartyLocation, Party), fieldNum(DirPartyTable, RecId));
    dataSourceDPT.fetchMode(QueryFetchMode::One2Many);
    dataSourceDPT.joinMode(JoinMode::InnerJoin);

    dataSourceCI = dataSourceDPT.addDataSource(tableNum(CompanyInfo), "CompanyInfo");
    dataSourceCI.addLink(fieldNum(DirPartyTable, RecId), fieldNum(CompanyInfo, RecId));
    dataSourceCI.fetchMode(QueryFetchMode::One2One);
    dataSourceCI.joinMode(JoinMode::InnerJoin);

Example:

Today I get

Record 1 - DataA DataB DataC A1 ID1 IDRelated1 RelatedData1 RelatedData1_2

Record 2 - DataX DataY DataZ B2 ID2 IDRelated1

And so on...

When I read the result in C# I get the relations but no record in each row. Is there a way to return the associated tables for each column even though they might be repeated in any previous row?

Thanks.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    240,163 Most Valuable Professional on at

    How are you "getting" the data?

  • Community Member Profile Picture
    on at

    Using QueryBuilder.

    I call a QueryService from C# and then the AifQueryBuilder custom class is executed returning the results.

  • Community Member Profile Picture
    on at

    I've tried using ReturnFlatDataset but it generated a quite large xml file.

    If possible I'd like to solve this on Dynamics end.

    Thanks.

  • Verified answer
    Community Member Profile Picture
    on at

    Solved.

    1 - I created a projection to select only the fields I wanted from each dataset:

    dataSourceDPL.fields().dynamic(NoYes::No);
    dataSourceDPL.fields().clearFieldList();
    dataSourceDPL.fields().addField(fieldNum(DirPartyLocation, RecId));
    dataSourceDPL.fields().addField(fieldNum(DirPartyLocation, Party));


    2 - Then at C# I just set the property ReturnFlatDataSet to true.

    That was it. :)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans