Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

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

Posted on by 5,901

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

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: when to make it datasource.relations(True) OR datasource.relations(false) ?

    Ohh.. Sorry

    Thanks Vilmos

  • Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: when to make it datasource.relations(True) OR datasource.relations(false) ?

    The opposite. Read what I said one more time.

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: when to make it datasource.relations(True) OR datasource.relations(false) ?

    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

  • Verified answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: when to make it datasource.relations(True) OR datasource.relations(false) ?

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans