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 the from email address for Print Management functionality.
As we all know, there is no option in standard to configure the sender email address for the Payment advice report or any other report which is printing through Print Management, except if we configure it by electronic reporting. So let's see how we can achieve this by doing a very small customization.
Please visit my previous blog for how to set email subject from print management.
If you look into the standard class SrsReportRunMailer
, there is a method buildFromEmailAddress()
. This method is picking the email address of the current user ID and using it as the 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 cannot create COC or event handler of it.
Please follow the below steps to complete this customization.
Step 1: Create a New Parameter
Create a new parameter in the accounts payable parameter form to store the from email address.
Step 2: Create a New Class
Create a new class to write COC of emailReport()
method. The class name should end with _Extension
. Example: TestSrsReportRunBuilder_Extension
[ExtensionOf(classStr(SrsReportRunMailer))]
public final class TestSrsReportRunBuilder_Extension
{
}
Step 3: Add the 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 defined in Print Management parameter.
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 :

Is there any way to include email body from email template under Organization Administration ?
ReplyDeleteHi Amit,
ReplyDeleteBy code I don't see there is any way we can pick email templates from organization and administration but you can check the post shared by Ian in comments box over LinkedIn,Also if you want to achive this by custom code then check my another blog.Link provided in code section of this blog.
Hi Vijay, where we can see the email body of the payment advice report, like in your email screen shot, or where we can find the email body for payment advice report.
ReplyDeleteHi Akbar,
ReplyDeleteThis email body is coming from custom field,
Please check this blog.
https://d365fotechnicalblog.blogspot.com/2022/05/modify-email-subject-and-body-of-print.html