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)

Print a report multiple copies based on parameter

(0) ShareShare
ReportReport
Posted on by 105

Hi everyone,

I add a new report and I want to print multiple times based on parameter that I write:

1602.1111.jpg

I add  this code to controller and it works:

  SrsReportRunController controller = new SrsReportRunController();
    SRSPrintDestinationSettings printSettings;

    // set report name
    controller.parmReportName(ssrsReportStr(LedgerBalanceControl, Report));

    // get print settings from contract
    printSettings = controller.parmReportContract().parmPrintSettings();

    // set printer as the destination
    printSettings.printMediumType(SRSPrintMediumType::Printer);
    printSettings.printerName = "My Printer"; // specify your printer name 
    printSettings.printLandscape(true); // print in landscape orientation
    printSettings.numberOfCopies(2);    // print 2 copies
    printSettings.setPaperTray(1); // print to paper tray with index = 1 
          
    printSettings.collate(true);          // collate printed copies

    // suppress the parameter dialog to send directly to printer
    controller.parmShowDialog(false);

    // start operation
    controller.startOperation();


But I do not know how to print using the parameter that i write in the dialog.

When I write printSettings.numberOfCopies(2) print two times but I want to print based on the parameter that i wrote.

*This post is locked for comments

I have the same question (0)
  • XB Profile Picture
    1,875 on at

    i think you need to create a UIBuilder Class and modified method getFromDialog, or postRun to get Dialog value.

  • Suggested answer
    DavidGunawan Profile Picture
    1,381 on at

    Hi Krychul,

    I think you can use the SSRS the contract class that you use to maintain the dialog. Then you can get the value of parameter and feed it to the printSettings.numberOfCopies().

    Regards

  • Krychul Profile Picture
    105 on at

    Thanks for the anwser,

    But How to pass parameter from Contract to Controller ?

  • XB Profile Picture
    1,875 on at

    look at main method of CustRecurrenceInvoicePostController, you'll see how to call contract from controller.

  • Krychul Profile Picture
    105 on at

    That not work.

    Because Controller run before Contract.

    Number of Copies i want to choice in the dialog that i upload up.

  • Suggested answer
    DavidGunawan Profile Picture
    1,381 on at

    I modified your code with a line to get number of page parameter.

    Actually, you don't have to write print settings set value in the controller class. You can it in contract or RDP class because print settings object is part of the contract.


    SrsReportRunController controller = new SrsReportRunController();
    SRSPrintDestinationSettings printSettings;
    int numOfPages = 0;

    // set report name
    controller.parmReportName(ssrsReportStr(LedgerBalanceControl, Report));

    // get print settings from contract
    printSettings = controller.parmReportContract().parmPrintSettings();

    // get number of pages parameter. You should write parmNumOfPages() method in the contract class
    numOfPages = controller.parmReportContract().parmNumOfPages();

    // set printer as the destination
    printSettings.printMediumType(SRSPrintMediumType::Printer);
    printSettings.printerName = "My Printer"; // specify your printer name
    printSettings.printLandscape(true); // print in landscape orientation
    printSettings.numberOfCopies(numOfPages); // print 2 copies
    printSettings.setPaperTray(1); // print to paper tray with index = 1

    printSettings.collate(true); // collate printed copies

    // suppress the parameter dialog to send directly to printer
    controller.parmShowDialog(false);

    // start operation
    controller.startOperation();

  • DavidGunawan Profile Picture
    1,381 on at

    Sorry please ignore the previous code. Please refers below:

    SrsReportRunController controller = new SrsReportRunController();
    SRSPrintDestinationSettings printSettings;

    //Define contract object by contract class of your parameter

    DataContractAttribute parmContract;

    int numOfPages = 0;

    // set report name
    controller.parmReportName(ssrsReportStr(LedgerBalanceControl, Report));

    // get print settings from contract
    printSettings = controller.parmReportContract().parmPrintSettings();

    //get the RDP contract

    parmContract = controller.parmReportContract().parmRdpContract();

    // get number of pages parameter. You should write parmNumOfPages() method in the contract class of the parameter
    numOfPages = parmContract.parmNumOfPages();

    // set printer as the destination
    printSettings.printMediumType(SRSPrintMediumType::Printer);
    printSettings.printerName = "My Printer"; // specify your printer name 
    printSettings.printLandscape(true); // print in landscape orientation
    printSettings.numberOfCopies(numOfPages); // print 2 copies
    printSettings.setPaperTray(1); // print to paper tray with index = 1 

    printSettings.collate(true); // collate printed copies

    // suppress the parameter dialog to send directly to printer
    controller.parmShowDialog(false);

    // start operation
    controller.startOperation();

  • Suggested answer
    XB Profile Picture
    1,875 on at

    Did you solve the problem? if not create a UIBuilder Class.

  • Krychul Profile Picture
    105 on at

    No,

    I didn't solve the problem.

    I have create a UIBuilder Class and add a three dialog fields like on the screen above.

  • XB Profile Picture
    1,875 on at

    get datacontract class on getfromDialog mthod and set values on the contract.

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans