Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Automatic printing SSRS report

Posted on by 114
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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans