Hi, You are adding the join condition twice qHeader.addRange(fieldnum(ALPurchReqTable, PurchReqId)) .value(strfmt(' (%1.%2 == %3.%4) ', purchReqLine_ds.query().dataSourceNo(1).name(), fieldStr(ALPurchReqLine, PurchReqId), purchReqLine_ds.query().dataSourceNo(2).name(), fieldStr(ALPurchReqTable, PurchReqId))); qHeader.addLink(fieldnum(ALPurchReqLine, PurchReqId),fieldnum(ALPurchReqTable, PurchReqId));
I cannot see your table relations, I assume you have any. I clear the dynalinks in the example. public void init() { QueryBuildDataSource qPurchReqLine, qHeader, qApproval; ; super(); qPurchReqLine = purchReqLine_ds.query().dataSourceTable(tablenum(ALPurchReqLine)); qPurchReqLine.addRange(fieldnum(ALPurchReqLine, PurchLineCreated)).value(SysQuery::value(NoYes::No)); // Add Header qHeader = qPurchReqLine.addDataSource(tablenum(ALPurchReqTable)); qHeader.ClearDynaLinks(); qHeader.joinMode(JoinMode::OuterJoin); qHeader.addLink(fieldnum(ALPurchReqLine, PurchReqId),fieldnum(ALPurchReqTable, PurchReqId)); qApproval = qHeader.addDataSource(tablenum(ALApprovalStatus)); qApproval.ClearDynaLinks(); qApproval.joinMode(JoinMode::OuterJoin); qApproval.addRange(fieldnum(ALApprovalStatus, AppStatusType)).value(queryValue(ALAppStatus::Approved)); qApproval.addLink(fieldnum(ALPurchReqTable, RecId),fieldnum(ALApprovalStatus, RefRecId)); qApproval.addLink(fieldnum(ALPurchReqTable, TableId),fieldnum(ALApprovalStatus, RefTableId)); } Mit freundlichen Grüßen / Best regards / Med venlig hilsen Jesper Jørgensen / Abt. NMT-XD Senior Product Manager arvato systems | Technologies GmbH An der Autobahn 18 33311 Gütersloh jesper.joergen...@bertelsmann.de<blocked::blocked::blocked::mailto:jesper.joergen...@bertelsmann.de> Phone: +49 5242 / 40 80 54 Fax: +49 5242 / 40 80 40 Mobile: +49 172 / 571 03 34 http://www.as-T.de<blocked::blocked::http://www.as-t.biz/> arvato systems | Technologies GmbH Joachim-Jungius-Str. 9, 18059 Rostock Geschäftsführung: Erwin Pietz, Matthias Moeller Amtsgericht Rostock - HRB 7497 ________________________________ "Der Inhalt dieser Nachricht oder eventueller Anlagen ist vertraulich und ausschließlich für den bezeichneten Adressaten bestimmt. Bitte stellen Sie sicher, dass die Information in dieser Nachricht ausschließlich an die adressierten Personen gelangt. Sollte diese Nachricht versehentlich an Sie gesendet worden sein, dann informieren Sie bitte umgehend den Absender und löschen Sie die Nachricht. Vielen Dank." "The information in this e-mail and any attachments is confidential. The information must only be held in areas that have controlled and limited access to the addressed persons. If this e-mail has been sent to you in error, please immediately notify the sender and delete the e-mail. Thanks." ________________________________ Von: development-axapta@yahoogroups.com [mailto:development-axa...@yahoogroups.com] Im Auftrag von benoit.billington Gesendet: Freitag, 4. September 2009 17:28 An: development-axapta@yahoogroups.com Betreff: [development-axapta] Select statement is easy but I have trouble making the QueryBuildDataSource I first created a job to see what I needed to do in 30sec it was done... easy query with multiple joins static void test(Args _args) { ALPurchReqLine line; ALPurchReqTable table; ALApprovalStatus status; ; while select line join table where line.PurchReqId == table.PurchReqId join status where status.RefRecId == table.RecId && status.RefTableId == table.TableId { info(strfmt("%1", line.ItemId)); } } but then when trying with the query object I have trouble :( public void init() { QueryBuildDataSource qPurchReqLine, qHeader, qApproval; ; super(); qPurchReqLine = purchReqLine_ds.query().dataSourceTable(tablenum(ALPurchReqLine)); qPurchReqLine.addRange(fieldnum(ALPurchReqLine, PurchLineCreated)).value(SysQuery::value(NoYes::No)); //TODO purchReqLine_ds.query().dataSourceTable(tablenum(ALPurchReqLine)).addRange(fieldnum(ALPurchReqLine, Status)).value(SysQuery::value(PurchReqStatus::Approved)); qHeader = qPurchReqLine.addDataSource(tablenum(ALPurchReqTable), tableStr(ALPurchReqTable)); qHeader.joinMode(JoinMode::OuterJoin); qHeader.addRange(fieldnum(ALPurchReqTable, PurchReqId)) .value(strfmt(' (%1.%2 == %3.%4) ', purchReqLine_ds.query().dataSourceNo(1).name(), fieldStr(ALPurchReqLine, PurchReqId), purchReqLine_ds.query().dataSourceNo(2).name(), fieldStr(ALPurchReqTable, PurchReqId))); qHeader.addLink(fieldnum(ALPurchReqLine, PurchReqId),fieldnum(ALPurchReqTable, PurchReqId)); qApproval = qHeader.addDataSource(tablenum(ALApprovalStatus), tableStr(ALApprovalStatus)); qApproval.joinMode(JoinMode::OuterJoin); qApproval.addRange(fieldnum(ALApprovalStatus, AppStatusType)).value(queryValue(ALAppStatus::Approved)); qApproval.addRange(fieldnum(ALApprovalStatus, RefTableId)).value(queryValue(tablenum(ALPurchReqTable))); qApproval.addRange(fieldnum(ALApprovalStatus, RefRecId)) .value(strfmt('(%3.%4 == %1.%2) ', purchReqLine_ds.query().dataSourceNo(2).name(), fieldStr(ALPurchReqTable, RecId), purchReqLine_ds.query().dataSourceNo(3).name(), fieldStr(ALApprovalStatus, RefRecId) )); qApproval.addLink(fieldnum(ALPurchReqTable, RecId),fieldnum(ALApprovalStatus, RefRecId)); qApproval.addLink(fieldnum(ALPurchReqTable, TableId),fieldnum(ALApprovalStatus, RefTableId)); } [Non-text portions of this message have been removed]