Wednesday, June 22, 2022

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 - 




3 comments:

  1. Is there any way to include email body from email template under Organization Administration ?

    ReplyDelete
  2. Hi Amit,
    By 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.

    ReplyDelete
  3. 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.

    ReplyDelete

How to Post Partial Product Receipt in D365FO Using X++ Code

How to Post Partial Product Receipt in D365FO Using X++ Code How to Post Partial Product Receipt in D365FO Using X++...