Wednesday, October 4, 2023

How to send Lasernet report PDF on email.

Calling Lasernet Report from X++ Code in Dynamics 365 Finance and Operations

Calling Lasernet Report from X++ Code in Dynamics 365 Finance and Operations

Published on October 4, 2023 by Your Name

Hi All,

I hope everybody is doing great and learning isn't stopped. Today, I am here with another article that will help us call a Lasernet report from X++ code in Dynamics 365 Finance and Operations. Let me explain my requirement. I have a requirement to send the SalesPackingSlipReport over email, but we don't want to use the standard report designs because we have implemented the ISV solution "Lasernet." So, here comes the challenge: how can we call it? I got some input from the below blog, but after that, I faced lots of problems, but finally, I have achieved it.

Lasernet User Guide

Prerequisites to follow
step 1 :


class FPPrintReport
{
    public static void main(Args _args)
    {
        CustPackingSlipJour custPackingSlipJour = CustPackingSlipJour::findRecId(5637146826);
        FPPrintReport::sendPackingSlipByEmail('200030-SHI-UK01', custPackingSlipJour, 
        	'vijay.yelmame14@gmail.com', 'Test.pdf');
    }

    public static void sendPackingSlipByEmail(WHSShipmentId _shipmentId, 
    	CustPackingSlipJour custPackingSlipJour, Email _ToEmail, Filename _fileName)
    {
        CustFormletterParameters custFormParm = CustFormletterParameters::find();

        if (custFormParm.TestEnableEmailPackSlipReport)
        {
            SalesPackingSlipController formLetterController = SalesPackingSlipController::construct();
            SRSPrintDestinationSettings destinationSettings = new SRSPrintDestinationSettings();
            destinationSettings.printMediumType(SRSPrintMediumType::LAC);

            LACDestinationSettings LACDestinationSettings = new LACDestinationSettings();
            LACDestinationSettings.destTypes4Print(LACDestTypes4Print::Email);
            
            LACDestinationSettings.emailFrom(custFormParm.TestFromEmailAddress);
            LACDestinationSettings.emailTo(_ToEmail);
            LACDestinationSettings.emailSubject(strFmt(custFormParm.TestEmailSubject, _shipmentId));
            LACDestinationSettings.emailBody(custFormParm.TestEmailBody);
            LACDestinationSettings.allowForcedReRun(NoYes::Yes);
            LACDestinationSettings.emailFromName('Test Test');

            destinationSettings.lacDestinationSettings(LACDestinationSettings);

            LACReport report = LACReport::find(ssrsReportStr(Salespackingslip, Report));
            LACResendReport::resendReportFromRecord(report.ReportName, custPackingSlipJour, destinationSettings, true);
        }
    }
}

That's it! You can now follow these steps to call Lasernet reports from your X++ code in Dynamics 365 Finance and Operations. This solution should help you send your SalesPackingSlipReport over email using Lasernet.

If you have any questions or encounter any issues, please feel free to ask. Happy coding!

Post partial packing slip in D365FO

How to Post a Partial Packing Slip in D365FO and AX 2012 How to Post a Partial Packing Slip in D365FO and AX 2012 Understanding t...