Showing posts with label How do you write a remittance advice email?. Show all posts
Showing posts with label How do you write a remittance advice email?. Show all posts

Wednesday, June 22, 2022

How to add sender email address for Payment remittance (Advice) in D365FO

How to Add Sender Email Address for Payment Remittance (Advice) in D365FO

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 :

Example Image

Update Values During Data Entity Import in D365FO

Update Values During Data Entity Import in D365FO Updating Field Values During Data Entity Import in Dynamics 365 Finance ...