Showing posts with label custom range in view. Show all posts
Showing posts with label custom range in view. Show all posts

Thursday, May 19, 2022

Modify email subject and body of Print Payment Advice email generated by Print Management

Hi all,
In this blog will learn how to modify the standard email subject and body generated through the Print Management.    

Requirement - 
1) Add vendor code in Subject line.
2) Modify email body - add vendor name and Legal entity name.

This can be achieve by doing small customization.

Solution/Steps

1) Create extension class for class - SRSPrintDestinationSettings and add below code.

[ExtensionOf(classstr(SRSPrintDestinationSettings))]
public final class TestSRSPrintDestinationSettings_Extension
{
    internal    str     reportTitle;
    internal    RecId   voucherRecId;
    //Type of report
    [DataMemberAttribute]
    public str reportTitle(str _reportTitle = reportTitle)
    {
        reportTitle = _reportTitle;
        return reportTitle;
    }
     [DataMemberAttribute]
    public RecId voucherRecId(RecId _voucherRecId = voucherRecId)
    {
        voucherRecId = _voucherRecId;
       return voucherRecId;
    }

  public SrsReportEMailDataContract parmEMailContract(SrsReportEMailDataContract _emailContract)

    {

        Notes                                       emailBOdy;
        SrsReportEmailDataContract  contract;
        LedgerJournalTrans              ledgerJournalTrans; 
        contract = next parmEMailContract(_emailContract);
        if (reportTitle == "Payment Advice")
        {

             emailSubject =     contract.parmSubject();
            select firstonly ledgerJournalTrans  where ledgerJournalTrans.RecId == voucherRecId;

            emailSubject =  strReplace(emailSubject,"%VendorAccount%",                                                                 ledgerJournalTrans.accountDisplay());

            contract.parmSubject(emailSubject);            

            emailBOdy = VendParameters::find().MTEmailBodyForPaymentAdvice;

            emailBOdy = strReplace(emailBOdy,"%VendorName%",ledgerJournalTrans.LedgerDimensionName);

        emailBOdy =             strReplace(emailBOdy,"%LegalEntityName%",CompanyInfo::findRecId(CompanyInfo::current()).Name);

            contract.parmBody(emailBody);    

        }
        return contract;

    }

}
Step 2 : Create COC for printReport() method of class SrsReportRunPrinter

[ExtensionOf(classStr(SrsReportRunPrinter))]
public final class TestSrsReportRunPrinter_extension
{
    public void printReport()
    {
        if (reportContract.parmRdpName() == "BankPaymAdviceVendDP")
        {
            BankPaymAdviceContract bankPaymAdviceContract = reportContract.parmRdpContract() as                 BankPaymAdviceContract;
            printSettings.reportTitle("Payment Advice");
            printSettings.voucherRecId(bankPaymAdviceContract.parmLedgerJournalTransRecId());
        }
        next printReport();
        }
}

Step 3 : Add new field for email template in AP parameter(VendParameter)

and paste below content 

Dear Sir's
<br>
Regarding payment to: %VendorName%
<br>
Please refer the attached payment advice.
<br>
Yours faithfully
<br>
%LegalEntityName%






  



 



Step 4 : Add setup in Print management 

Refer below highlighted path 














































Result -










Saturday, March 19, 2022

How to add custom range method to apply range on View.

Hi All,
In this blog will learn how to add range method same as  SysQueryRangeUtil methods and apply on view.

Requirement - Add range in view to take only records up to last month ( Today() – days of current date)  i.e equal to up to last month transactions

Solution -  Create new class and add method according to the range and copy method attribute [QueryRangeFunction]

x++ Code
public static class TestVoyageClass
{
 [QueryRangeFunction]
public static str lessthanLastMonth()
{
int days ;
utcdatetime currentDateTime;
currentDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());
days = DateTimeUtil::day(currentDateTime)-1;
return SysQueryRangeUtil::lessThanDate(-days);
}
}
Add method name in range property of view. 


 







Thats It !!

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