[ExtensionOf(classStr(SRSPrintDestinationSettings))]
final class SRSPrintDestinationSettings_Extension
{
[SubscribesTo(classStr(SRSPrintDestinationSettingsDelegates), delegateStr(SRSPrintDestinationSettingsDelegates, toSendEmail))]
public static void SRSPrintDestinationSettingsDelegates_toSendEmail(System.Byte[] reportBytes, SrsReportRunPrinter printer, SrsReportDataContract dataContract,Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] paramArray, EventHandlerResult result)
{
CustParameters parameters = CustParameters::find();
str messageBody;
SysEmailMessageTable message;
LanguageId languageId = CompanyInfo::find().LanguageId;
SRSPrintDestinationSettings printSettings = dataContract.parmPrintSettings();
SysEmailTable sysEmailTable = SysEmailTable::find(parameters.EmailTemplate);
Filename fileName;
SalesConfirmContract contract = new SalesConfirmContract();
SalesTable salesTable;
SalesLine salesLine;
CustConfirmJour custConfirmJour;
Map mappings = new Map(Types::String, Types::String);
ServiceOrderBatchJobService service = new ServiceOrderBatchJobService();
contract = dataContract.parmRdpContract();
custConfirmJour = CustConfirmJour::findRecId(contract.parmRecordId());
select firstonly salesTable
where salesTable.SalesId == custConfirmJour.SalesId;
select firstonly salesLine
where salesLine.SalesId == salesTable.SalesId;
if(!languageId)
{
languageId = sysEmailTable.DefaultLanguage;
}
// Place holders
mappings = service.placeHolders(salesTable,salesLine,'');
message = SysEmailMessageTable::find(sysEmailTable.EmailId, sysEmailTable.DefaultLanguage);
messageBody = message.Mail;
messageBody = SysLabel::resolveLabels(messageBody, languageId);
messageBody = SysEmailMessage::stringExpand(messageBody, SysEmailTable::htmlEncodeParameters(mappings));
fileName = SysEmailMessage::stringExpand(printSettings.parmFileName(), SysEmailTable::htmlEncodeParameters(mappings));
printSettings.parmEMailContract().parmBody(messageBody);
printSettings.parmFileName(fileName);
}
}