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

Announcements

No record found.

News and Announcements icon
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,244

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,735 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,244 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,244 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans