When emailing customers their sales order confirmation we need to attach the ‘Safety data sheet’ for each product on the sales order lines as an attachment on the email.
Using print management email attachment rules we can successfully attach any attachment associated with released product line items but is there a way to include the product safety data sheet which is attached under the ‘released product > Manage Inventory > Compliance > Safety data sheet’?
Docentric does not have the option to include the SDS attachments when sending the sales invoice via email. However, we can help you by providing sample code for implementing the “Custom records” attachment rule for the Docentric Email print destination.
To learn more about additional report attachments, please see the link below: Report Attachments - Docentric AX
To receive the attachments from SDS as additional email attachments when you email the sales invoice, you will need to configure additional attachment rules under the Docentric Email print destination:
As indicated in the instructions (see the yellow highlighted text in the image above), this attachment rule needs to be implemented in the code of the DSP class.
To help you with this code implementation, I am sending you a code example that shows how it can be done:
protected Common resolveReportAttachmentRecord(DocReportRunContext _reportRunContext, DocReportAttachmentRule _currentAttachmentRule)
{
// If a _currentAttachmentRule is CustomRecords we need to select and return a PdsMRCDocument table buffer
if (_currentAttachmentRule.parmLoadFrom() == DocReportAttachmentLoadFrom::CustomRecords)
{
PdsMRCDocument pdsMRCDoc;
SalesLine salesLineLocal;
select pdsMRCDoc
where pdsMRCDoc.Active == NoYes::Yes && pdsMRCDoc.EffectiveDate <= today() && pdsMRCDoc.ExpiryDate >= today()
exists join salesLineLocal where salesLineLocal.ItemId == pdsMRCDoc.ItemId && salesLineLocal.SalesId == salesTable.SalesId;
return pdsMRCDoc;
}
else
{
return super(_reportRunContext, _currentAttachmentRule);
}
}
The resolveReportAttachmentRecord () method needs to be implemented in the DSP class.
I suggest that you create a new DSP class that inherits from the DocSalesConfirmReportDSP class, or you can implement this method in your own DSP class if you have one.