vukis
vukis

Reputation: 381

VendInvoiceJour.InvoiceAccount <- VendTable.AccountNum relation

I have following situation: I need to join VendInvoiceJour.InvoiceAccount <- VendTable.AccountNum and take VendTable.Vendgroup. In all cases (queries,or even views) Dynamics ax joins tables VendInvoiceJour.OrderAccount<- VendTable.AccountNum not VendInvoiceJour.InvoiceAccount <- VendTable.AccountNum. I`m trying to use this kind of query:

qBdSVendJour = element.query().dataSourceTable(tablenum(VendInvoiceJour));
qBdSVendTbl = qBdSVendJour.addDataSource(tablenum(VendTable));
qBdSVendTbl.relations(true);
qBdSVendTbl.joinMode(JoinMOde::InnerJoin);
qBdSVendTbl.fetchMode(QueryFetchMode::One2One);

qBdSVendTbl.addLink(
    FieldNum(VendInvoiceJour,InvoiceAccount)
    ,FieldNum(VendTable,AccountNum)
); //(Dynamics ax automatically corrects InvoiceAccount to orderaccount 
   //in reports if trying this link in morphx)

Upvotes: 0

Views: 1116

Answers (3)

carrerdedalt
carrerdedalt

Reputation: 86

If you remove the line:

  *qBdSVendTbl.relations(true);*

then you won't need to add:

  *BdSVendJour.clearDynalink();*

To be sure that the actual query is the expected print the conent of:

  *qBdSVendJour.toString();*

Upvotes: 1

Tommy Skaue
Tommy Skaue

Reputation: 11

I believe the statement qBdSVendTbl.relations(true) will have AX evaluate the defined relations on the tables in question and use them regardless.

Upvotes: 0

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18061

qBdSVendJour.clearDynalink() will do the trick.

Upvotes: 0

Related Questions