Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 73760

RDP Complex join/Query Build data source

$
0
0

Hello,

A real AX new developer here so if something seems out of sorts....

I am working on an SSRS report. They are wanting the option to group/not group the detail at run time. The basic SQL for this looks like;

SELECT * FROM dbo.ProjInvoiceJour t1

inner join dbo.ProjProposalItemTrans t2 on t1.ProposalId = t2.ProposalId

inner join dbo.RRMArrangementVersionTable t3 on t2.projid = t3.ReferenceId

inner join dbo.RRMArrangementVersionElement t4 on t3.recid = t4.arrangementversion

WHERE ((packageItemId = '') OR (packageItemId = ItemId)) AND ((InvoiceDate>={ts '2013-01-28 00:00:00.000'} AND InvoiceDate<={ts '2013-01-29 00:00:00.000'}))  

That returns a proper data set. So in my RDP this is how things are shaping up;

   queryBuildDataSource = query.addDataSource(tablenum(RRMArrangementVersionElement));

   queryBuildDataSource = queryBuildDataSource.addDataSource(tableNum(RRMArrangementVersionTable));

   queryBuildDataSource.joinMode(JoinMode::InnerJoin);

   queryBuildDataSource.relations(false);

   queryBuildDataSource.addLink(fieldNum(RRMArrangementVersionElement, ArrangementVersion), fieldNum(RRMArrangementVersionTable, RecId));

   queryBuildDataSource = queryBuildDataSource.addDataSource(tableNum(ProjProposalItemTrans));

   queryBuildDataSource.joinMode(JoinMode::InnerJoin);

   queryBuildDataSource.relations(false);

   queryBuildDataSource.addLink(fieldNum(ProjProposalItemTrans, ProjId), fieldNum(RRMArrangementVersionTable, ReferenceId));    

   queryBuildDataSource = queryBuildDataSource.addDataSource(tableNum(ProjInvoiceJour));

   queryBuildDataSource.joinMode(JoinMode::InnerJoin);

   queryBuildDataSource.relations(false);

   queryBuildDataSource.addLink(fieldNum(ProjInvoiceJour, ProposalId), fieldNum(ProjProposalItemTrans, ProposalId));

   if(FromDate && ToDate)

   {

       queryBuildRange = queryBuildDataSource.findRange(fieldnum(ProjInvoiceJour, invoiceDate));

       if (!queryBuildRange)

       {

           queryBuildRange = queryBuildDataSource.addRange(fieldnum(ProjInvoiceJour, invoiceDate));

       }

       // If an account number has not been set, then use the parameter value to set it.

       if(!queryBuildRange.value())

           queryBuildRange.value(QueryRange(fromDate,Todate));

   }

   if(groupedChecked)

   {

       queryBuildRange.value(strFmt('(((%1 == %2) (%1 == %4)) && ((%5 >= %6) && (%5 <= %7)))',

       fieldStr(RRMArrangementVersionElement, packageItemId),

       sysquery::valueEmptyString(),

       fieldStr(RRMArrangementVersionElement, PackageItemId),

       fieldStr(RRMArrangementVersionElement, ItemId),

       fieldStr(ProjInvoiceJour, invoiceDate),

       Date2StrXpp(fromDate),

       date2StrXpp(ToDate)));

   }

But thinks aren't working right. Am I barking up the wrong tree? Is there a better way to go about this?

Thanks!


Viewing all articles
Browse latest Browse all 73760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>