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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Automatic printing SSRS report

(0) ShareShare
ReportReport
Posted on by 112
Hi everyone,
 
I have this requirement where I have to send the custom SSRS report to the printer automatically, after a certain activity completes.
So there's this warehouse app, from there users do some pick activity and on the last line of pick, I send this SSRS report to the printer.
 
Users select the printer on frontend, that is also a custom field. And it uses Document Routing Agent(DRA) for printing. 
 
So for testing in dev environment, we are using a dummy printer which we created, and it shows report in the queue of DRA. But when we do the same process in test environments, the automatic thing is not working, not even the dummy printer works. Now, we don't understand whether the problem is with code or configuration. So can someone please, look at the code and let me know if its correct or not.
Also if anyone can give any ideas/suggestion/solutions for this problem.
 
Note, that manual printing is working when someone clicks on the report's output menuitem.
 
Here's the code that I wrote in the controller to send the report to printer.
 
public PrinterName getPrinterName()
    {
        PrinterName     printerName;
        WHSWorkUser     whsWorkUser = WHSWorkUser::find(userId);
        WHSWorker       whsWorker = WHSWorker::find(whsWorkUser.Worker);
        DirPersonUser   personUser;
        HcmWorker       worker;
        printerName = whsWorkUser.DefaultPrinterNameHeader_Custom;
       
        if (!printerName)
        {
            throw error(/Default printer not found/);
        }
        return printerName;
    }
 
 
public static void main(Args _args)
    {
        WHSWorkController_Custom whsWorkController = new WHSWorkController_Custom();
        whsWorkController.parmReportName(ssrsReportStr(WorkPickReport_Custom, Report));
        whsWorkController.parmArgs(_args);
        whsWorkController.parmDialogCaption(/Work Pick Report/);
        whsWorkController.setRange(_args, whsWorkController.parmReportContract().parmQueryContracts().lookup(whsWorkController.getFirstQueryContractKey()));
        if(_args.menuItemName() == menuItemOutputStr(WorkPickMenuItem_Custom) && _args.parm() != '@SYS300876')
        {
            whsWorkController.parmShowDialog(true);
        }
        else
        {
            PrinterName printerName = whsWorkController.getPrinterName();
           
            SRSPrintDestinationSettings srsPrintDestinationSettings = new SRSPrintDestinationSettings();
            srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::Printer);
            srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
            srsPrintDestinationSettings.printerName(printerName);
            whsWorkController.parmReportContract().parmPrintSettings(srsPrintDestinationSettings);
            whsWorkController.parmShowDialog(false);
        }
        whsWorkController.startOperation();
    }
 
And Here's the custom field which selects the printer name.////////
 
Please provide some suggestion which could help with this thing.
 
Thanks,
Bhagyashree Dave
I have the same question (0)

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

Product updates

Dynamics 365 release plans