web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Dynamic subject line for purch order report emails

(0) ShareShare
ReportReport
Posted on by 1,215

Hi all,

I am trying to edit PurchPurchaseOrderController class to add a custom email subject in DAX 2012 R3, but the subject line gets overwritten when it reaches formLetterController.startOperation();

Any suggestion is appreciated. Thank you!

P.S.: I am trying to only modify the aforementioned class, and not write any job or class to run the report to send emails. I hope that is possible.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    how are you setting filename ? Are you setting it in SRSPrintDestinationSettings object and then passing those settings to controller ?

    see below example I am doing the same thing and its working for me , I am doing this in a batch.

    SrsReportRunController          controller = new SrsReportRunController();
            HRMParameters                   parameter = HRMParameters::find();
            SRSPrintDestinationSettings     settings;
            FilePath                        outputFilePath;
            Str1260                         subject,body;
            
            ;
    
            subject = "active employee report";
            body = "your hTML body"
    
           
            // Define report and report design to use
            controller.parmReportName(ssrsReportStr(ReconReport, PrecisionDesign1));
    
            // Use execution mode appropriate to your situation
            //controller.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch);
    
            // Suppress report dialog
            controller.parmShowDialog(false);
    
            controller.parmLoadFromSysLastValue(false);
    
    
            // SrsReportDataContract srsReportDataContract = controller.parmReportContract();
            //srsReportDataContract.parmisMemoryStreamOnly(true);
            //controller.parmReportContract(srsReportDataContract);
    
            // Change print settings as needed
            settings = controller.parmReportContract().parmPrintSettings();
            // set the print destination in contract
            settings.overridePrintContractSettings(true);
            
            settings.printMediumType(SRSPrintMediumType::Email);
            settings.emailAttachmentFileFormat(SRSReportFileFormat::Excel);
            settings.emailTo(email@gmail.com);
            settings.emailSubject(subject);
            settings.fileName('ReconData');
            settings.parmEMailContract().parmBody(body);
            //settings.overwriteFile(true);
    
          
    
            controller.parmReportContract().parmPrintSettings(settings);
            // Execute the report
            controller.startOperation();
    

  • Abhinay Tharwal Profile Picture
    1,215 on at

    Hi Sukrut,

    Thank you for your reply.

    I guess it is not about the file name. In the PurchPurchaseOrderController class's main method I tried

    formLetterController.parmReportContract().parmPrintSettings().emailSubject("Test");
    formLetterController.startOperation();


    and other methods those I have tried are:

    protected void preRunModifyContract()
    {
        this.parmReportContract().parmPrintSettings().emailSubject("Test");
        super();
        this.parmReportContract().parmPrintSettings().emailSubject("Test");
    }

    protected void postReportRun(SRSReportExecutionInfo _executionInfo)
    {
        this.parmReportContract().parmPrintSettings().emailSubject("Test");
        super(_executionInfo);
        this.parmReportContract().parmPrintSettings().emailSubject("Test");
    }


    To clarify where I have setup the to email id:

    AP>Setup>Forms>Form setup>Print management button>Purchase order>Destination>Print setup>Email


    I also tried your approach, which did not yield any different result:

    public static void main(Args _args)
    {
        SrsReportRunController          formLetterController = PurchPurchaseOrderController::construct();
        PurchPurchaseOrderController    controller;
        SRSPrintDestinationSettings     settings;
    
        if (TradeFormHelper::isCalledFromForm(_args, formStr(VendPurchOrderJournalListPage)))
        {
            _args.record(VendPurchOrderJour::findRecId(_args.record().RecId));
        }
    
        controller = formLetterController;
        controller.initArgs(_args, ssrsReportStr(PurchPurchaseOrder, Report));
    
        if (classIdGet(_args.caller()) == classNum(PurchPurchOrderJournalPrint))
        {
            formLetterController.renderingCompleted += eventhandler(purchPurchOrderJournalPrint::renderingCompleted);
        }
        settings = controller.parmReportContract().parmPrintSettings();
        settings.overridePrintContractSettings(true);
        settings.emailTo("email@domain.com");
        settings.emailSubject("Test");
        formLetterController.parmReportContract().parmPrintSettings(settings);
        formLetterController.startOperation();
    }


  • Verified answer
    Abhinay Tharwal Profile Picture
    1,215 on at

    Print management customization this link seems to be the only way of doing it. I will update the post if I get successful.

  • Suggested answer
    Muhammad Afsar Khan Profile Picture
    2,676 on at

    Hi, I know its too late but I faced similar issue where i should alter Email subject of my SSRS report. I simply override runReport() method and changed the email subject as per my requirement.

    public void runReport()
    {
        if (reportContract.parmPrintSettings().printMediumType() == SRSPrintMediumType::Email)
        {
            reportContract.parmPrintSettings().emailSubject('This is sample test email subject');
        }
        super();
    }

    Regards,

    Afsar

  • Anuradha Pandrangi Profile Picture
    260 on at

    Hi Afsar,

    I have the same requirement and when i tried your solution it is not working for me.

    Can you please let me know what exactly you did.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans