The problem is that all the logic works fine until I get to the data provider class. The correct PackingSlipId value is passed in the method, but when I set the breakpoint to in the DP class, the PackigSlipId is different than what was passed in. As a result, the wrong document is attached in the email message
{
SrsReportRunController srsReportRunController = new SrsReportRunController();
SRSPrintDestinationSettings settings;
custPackingSlipJour custPackingSlipJour;
SalesPackingSlipContract contract = new SalesPackingSlipContract();
Args args = new Args();
CustPackingSlipTrans custPackingSlipTrans;
CustInvoiceTrans custInvoiceTrans;
System.IO.MemoryStream memoryStream;
SRSReportRunService srsReportRunService = new SrsReportRunService();
Map reportParametersMap;
Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray;
SRSProxy srsProxy;
System.Byte[] reportBytes = new System.Byte[0]();
SRSReportExecutionInfo reportExecutionInfo = new SRSReportExecutionInfo();
SRSCatalogItemName reportDesignLocal;
LanguageId languageId;
Common printMgmtReferencedTable;
FormLetterReport formLetterReport;
PrintMgmtPrintSettingDetail printSettingDetail;
PrintMgmtReportFormatName printMgmtReportFormatName = PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderPackingSlip).getDefaultReportFormat();
reportDesignLocal = printMgmtReportFormatName;
select firstOnly custInvoiceTrans
where custInvoiceTrans.SalesId == _custInvoiceJour.SalesId
&& custInvoiceTrans.InvoiceId == _custInvoiceJour.InvoiceId
&& custInvoiceTrans.InvoiceDate == _custInvoiceJour.InvoiceDate
&& custInvoiceTrans.numberSequenceGroup == _custInvoiceJour.numberSequenceGroup;
select firstOnly custPackingSlipTrans
where custPackingSlipTrans.InventTransId == custInvoiceTrans.InventTransId;
if(custPackingSlipTrans)
{
custPackingSlipJour = custPackingSlipJour::findFromCustPackingSlipTrans(custPackingSlipTrans.SalesId,custPackingSlipTrans.PackingSlipId,custPackingSlipTrans.DeliveryDate);
SalesTable salesTable = custPackingSlipJour.salesTable();
{
reportDesignLocal = ssrsReportStr(MySalesPackingSlip, Report);
}
languageId = salesTable.LanguageId ? salesTable.LanguageId : custPackingSlipJour.LanguageId;
formLetterReport.loadPrintSettings(custPackingSlipJour, printMgmtReferencedTable, custPackingSlipJour.LanguageId);
{
printSettingDetail = formLetterReport.getCurrentPrintSetting();
formLetterReport.parmReportRun().loadSettingDetail(printSettingDetail);
}
contract.parmTableId(custPackingSlipJour.TableId);
srsReportRunController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
srsReportRunController.parmShowDialog(false);
srsReportRunController.parmReportContract().parmRdpContract(contract);
srsReportRunController.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
//memorystream
srsReportRunService.getReportDataContract(srsReportRunController.parmReportContract().parmReportName());
srsReportRunService.preRunReport(srsReportRunController.parmreportcontract());
reportParametersMap = srsReportRunService.createParamMapFromContract(srsReportRunController.parmReportContract());
parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);
srsProxy = SRSProxy::constructWithConfiguration(srsReportRunController.parmReportContract().parmReportServerConfig());
reportBytes = srsproxy.renderReportToByteArray(srsReportRunController.parmreportcontract().parmreportpath(), parameterValueArray, settings.fileFormat(), settings.deviceinfo());
memoryStream = new System.IO.MemoryStream(reportBytes);
//memorystream
}
}