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

Notifications

Announcements

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
    238,024 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

News and Announcements

Season of Giving Solutions is Here!

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
user5555 Profile Picture

user5555 2

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans