Skip to main content

Notifications

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

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Is it possible to return related data in each row?

    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. :)

  • Community Member Profile Picture
    on at
    RE: Is it possible to return related data in each row?

    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.

  • Community Member Profile Picture
    on at
    RE: Is it possible to return related data in each row?

    Using QueryBuilder.

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

  • Martin Dráb Profile Picture
    233,741 Most Valuable Professional on at
    RE: Is it possible to return related data in each row?

    How are you "getting" the data?

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
Zain Mehmood Profile Picture

Zain Mehmood 6 Moderator

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans