How to add sender email address for Payment remittance (Advice) in D365FO
Hi All,
Thank you for visiting this blog. This blog is all about how to set from email address for Print Management functionality.
As we all know there is no option in standard to configure sender email address for Payment advice report or any other report which is printing through Print management, except if we configure it by electronics reporting. So lets see how can achieve this by doing very small customization.
If you look into the standard class (SrsReportRunMailer) there is method buildFromEmailAddress(). This method is picking email address of current user id and using as from email address, this we want to change to the custom parameter. i.e. Test@gmail.com.
PS - I am writing COC of emailReport() method of class SrsReportRunMailer because buildFromEmailAddress() method is declared as private so we can not create COC or event handler of it.
Please follow below steps to complete this customization.
Step 1: Create new parameter in accounts payable parameter form to store from email address.
Step 2 : Create new class to write COC of emailReport() method.
Class name should be end with _Extension. Ex . TestSrsReportRunBuilder_Extension
[ExtensionOf(classStr(SrsReportRunMailer))]
public final class TestSrsReportRunBuilder_Extension
{
}
Step 3 : Add below code
public boolean emailReport(SrsReportEMailDataContract emailContract, System.Byte[] reportBytes, str fileName)
{
str tofindStr = 'Payment advice'; // this string should be present in email subject which can be define in //Print Management parameter. Please refer link for more details about how to setup email subject.
str emailSubject = emailContract.parmSubject();
if(strScan(emailSubject,tofindStr,1,strLen(emailSubject)))
{
fromAddress = VendParameters::find().TestFromEmailAddressPaymentAdvice;
mailer = this.parmSysMailer();
if (!fromAddress || !SysEmailDistributor::validateEmail(fromAddress))
{
error(strfmt("@SYS134596", "@SYS4083"));
}
}
// Next call
boolean ret = next emailReport(emailContract,reportBytes,fileName);
return ret;
}
Expected result -
This was originally posted here.
*This post is locked for comments