Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
Posted on by 5,943

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,943 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,943 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!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans