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)

when to make it datasource.relations(True) OR datasource.relations(false) ?

(0) ShareShare
ReportReport
Posted on by 56

Dear All,

I wrote below query and it's working fine. I have one question when to make it datasource.relations(True) OR datasource.relations(false) ?

static void TM_AS_Query(Args _args)
{
Query query;

QueryBuildDatasource datasource;
;
query = new Query();// Add SalesTable main datasource

datasource = query.addDataSource(tableNum(SalesTable)); 
datasource = datasource.addDataSource(tableNum(SalesLine)); 
datasource.joinMode(JoinMode::InnerJoin); 
datasource.relations(false); 

datasource.addLink(fieldNum(SalesTable, SalesId), fieldNum(SalesLine, SalesId));

}

Please give me more shed on this.

Thanks!

Arpan Sen

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    It is quite obvious. If there is relations defined between the tables or their EDTs are linked to tables, AX would know what the relation is, in which case setting relations(true) would establish the connection between them for you automagically.

    If there are no relations defined or you want to change how they are linked, you can override that with relations(false), and define how to link, based on what record context.

  • @rp@n Profile Picture
    56 on at

    Thanks Vilmos,

    As i understood means if i am going to create a relation between SalesTable and SalesLine with Sales Id filed ( Which is already there in SalesLine table) so, i need to make it

    QueryBuildDatasource     qbdsSalesTable, qbdsSalesLine;

    qbdsSalesTable.relations(false);  // False

    If i want to do some other relation which is not exist in SalesLine table then i need to put

    qbdsSalesTable.relations(True);  // True

    Please verify.

    Thanks!

    Arpan Sen

  • Vilmos Kintera Profile Picture
    46,149 on at

    The opposite. Read what I said one more time.

  • @rp@n Profile Picture
    56 on at

    Ohh.. Sorry

    Thanks Vilmos

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 July 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