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.
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))
]