Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)
Answered

How to add a dynamically created print setting (X++) without overwriting the print settings from the print management form?

(0) ShareShare
ReportReport
Posted on by 50

Hello everybody,

I am stuck on one last thing, where I'd appreciate your help.
I have the requirement to print, based on a checkbox value, an additional report-design that prints with the sales invoice.

So it should always be the sales invoice report (the print management settings) + conditionally an additional design.

I've added this method loadAdditionalPrintSetting to the SalesInvoiceController method:

4162.pic1.png

This method is called within the runPrintMgmt method of the SalesInvoiceController class right after this line:
3513.pic2.png

If I run this, it only prints my new design but ignores the print management settings.  Why is it throwing away the previously loaded print settings?  How to prevent this?

Thank you very much for your help in advance.

*This post is locked for comments

  • Verified answer
    Jannik Profile Picture
    Jannik 50 on at
    RE: How to add a dynamically created print setting (X++) without overwriting the print settings from the print management form?

    Solved it myself!  In the method PrintMgmtReportRun.loadSettingDetail() the object printSetting is instantinated again, and thus, the old settings were overwritten, when I called _formLetterReport.parmReportRun().loadSettingDetail()., as can be seen here (marked orange):

    public void loadSettingDetail(PrintMgmtPrintSettingDetail _settingDetail, str _documentKeyValue = '')
    {
        printSetting = new PrintMgmtPrintSetting();
        printSetting.addPrintDetail(_settingDetail);
        documentKeyValue = _documentKeyValue;
        this.reset();
    }

    So what I did was create a parm method in the PrintMgmtReportRun class, which returns the printSetting object. I now use this object to add my new print setting dynamically during runtime.  The method loadAdditionalPrintSetting() now has this snipped of code at the end instead of _loadLetterReport.parmReportRun().loadSettingDetail(printSettingDetail, ''):

        printSetting = _formLetterReport.parmReportRun().parmPrintMgmtPrintSetting();
        printSetting.addPrintDetail(printSettingDetail);
        _formLetterReport.parmReportRun().reset(); 

    I hope this helps somebody out there! :)  I wish you all a good night.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans