Problems adding new fields and fetching Query in data provider

Hi!

I have a few questions regarding reports in D365. I am trying to change the report WHSPickistShipping. It´s a report based on a Query. The Query contains 2 tables, see picture below.2019-01-22_09-52-47.jpg

My first attempt is to add display methods to an extension of WHSWorkline and then use these in the report. Adding the newly created methods to the report works fine but as I run the report the values turns up empty?? When I google it it seems that this function does not work correctly. Is that correct or should this be working?

After this I tried to change above Query and add InventTable on the same level as SalesTable but regardless of how I change fetchmode the new values turns up empty or too many record are fetched.

The third attempt is to change the report to use a Dataprovider. Changing the report itself works fine but the dataprovider does not seem to receive the Query ranges that are added in PreRunModifyContract() method in controller class.

This class is a printmgmt class so maybe it works differenty??

class STA030WHSPickListShippingController extends SrsPrintMgmtController

{

protected void preRunModifyContract()

{

this.setRanges();

}

private void setRanges()

{

QueryBuildRange queryBuildRange;

Query q = this.getFirstQuery();

QueryBuildDataSource queryBuildDataSource = SysQuery::findOrCreateDataSource(q, tableNum(WHSWorkLine));

this.buildRange();

if (this.parmArgs().dataset() == tableNum(WHSLoadTable))

{

queryBuildRange = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(WHSWorkLine, LoadId));

queryBuildRange.value(range);

}

else if (shipmentRange)

{

queryBuildRange = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(WHSWorkLine, ShipmentId));

queryBuildRange.value(range);

}

else if (range) // If not a load or shipment range then must be a producation order range

{

queryBuildRange = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(WHSWorkLine, OrderNum));

queryBuildRange.value(range);

QueryBuildDataSource whsWorkTable = SysQuery::findOrCreateDataSource(q, tableNum(WHSWorkTable));

QueryBuildRange workTableRange = SysQuery::findOrCreateRange(whsWorkTable, fieldNum(WHSWorkTable, WorkTransType));

workTableRange.value(queryValue(WHSWorkTransType::ProdPick));

}

}

protected void runPrintMgmt()

{

switch (this.parmArgs().dataset())

{

case tableNum(WHSWaveTable):

if (WHSWaveTable::getWorkTransType(this.parmArgs().record().(fieldNum(WHSWaveTable, WaveId))) == WHSWorkTransType::ProdPick)

{

printMgmtReportRun = PrintMgmtReportRun::construct(PrintMgmtHierarchyType::WHS, PrintMgmtNodeType::WHS, PrintMgmtDocumentType::WHSPickListProd);

}

else

{

printMgmtReportRun = PrintMgmtReportRun::construct(PrintMgmtHierarchyType::WHS, PrintMgmtNodeType::WHS, PrintMgmtDocumentType::WHSPickListShippingWave);

}

break;

case tableNum(WHSLoadTable):

printMgmtReportRun = PrintMgmtReportRun::construct(PrintMgmtHierarchyType::WHS, PrintMgmtNodeType::WHS, PrintMgmtDocumentType::WHSPickListShippingLoad);

break;

case tableNum(WHSShipmentTable):

printMgmtReportRun = PrintMgmtReportRun::construct(PrintMgmtHierarchyType::WHS, PrintMgmtNodeType::WHS, PrintMgmtDocumentType::WHSPickListShippingShipment);

break;

}

printMgmtReportRun.parmReportRunController(this);

printMgmtReportRun.load(this.parmArgs().record(), this.parmArgs().record(), Global::currentUserLanguage());

this.outputReports();

}

///

/// Builds range for the report.

///

void buildRange()

{

WHSWaveLine waveLine;

WHSProdWaveLine prodWaveLine;

switch (this.parmArgs().dataset())

{

case tableNum(WHSWaveTable):

WHSWaveTable waveTable = this.parmArgs().record();

while select ShipmentId from waveLine

where waveLine.WaveId == waveTable.WaveId &&

waveLine.ShipmentId != ‘’

{

shipmentRange = true;

if (!range)

{

range = waveLine.ShipmentId;

}

else

{

range += ‘,’ + waveLine.ShipmentId;

}

}

while select ProdId from prodWaveLine

where prodWaveLine.WaveId == waveTable.WaveId &&

prodWaveLine.ProdId != ‘’

{

if (!range)

{

range = prodWaveLine.ProdId;

}

else

{

range += ‘,’ + prodWaveLine.ProdId;

}

}

break;

case tableNum(WHSShipmentTable):

WHSShipmentTable shipmentTable = this.parmArgs().record();

range = shipmentTable.ShipmentId;

shipmentRange = true;

break;

case tableNum(WHSLoadTable):

WHSLoadTable loadTable = this.parmArgs().record();

range = loadTable.LoadId;

break;

}

}

}

And my added Dataprovider looks as below

[

SRSReportQueryAttribute(queryStr(WHSPickListShippingReport))

]

class STA030WHSPickListShippingReportDP extends SRSReportDataProviderBase

{

STA030WHSPickListShippingContract contract;

STA030WHSPickListShippingReportTmp whsPickListShippingReportTmp;

///

/// Fetches the STA030WHSPickListShippingReportTmp temporary table.

///

///

/// The temporary table.

///

[

SRSReportDataSetAttribute(tableStr(WHSLoadListTmp))

]

Display methods(On extension) won’t work in SSRS report. Try to add the new datasource to ur existing query with correct join and fetch mode… Then will get the field in SSRS report. One possible way is create extension of your existing query and add join the tables using relations

Thank you, I managed to solve this by creating my own controller class to the dataprovider I changed the report to. I had to change the extension to not extend SrsPrintMgmtController like standard. When I extend SrsReportRunController the query works fine. Pretty weird actually that the query is lost on the way. But if someone has a similar problem you have a way around it.

To change the query if the report is based on a query works fine as long as you do not have a query with tables on the same level. It actually makes the data to dissapear even though it worked fine in x++ code. I changed the fetchmode and got it to work perfectly when I tried to use the query in a class as a test to se if it worked as it should. I think there are several prolbems with the new ssrs that makes it difficult when the report is query-based.