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 :
Supply chain | Supply Chain Management, Commerce
Suggested Answer

How can I implement saving SSRS reports to a print archive after executing in batch mode?

(2) ShareShare
ReportReport
Posted on by 154
Hello Experts,
 
How can I implement saving SSRS reports to a print archive after executing in batch mode?
I have implemented the Controller class as follows, but it is not saved to the print archive.
If it is not in batch mode, it is downloaded to the download folder, but it is not saved to the print archive.
Can you please guide me on how to implement it?
Thanks in advance.
 
class xx_myController extends SrsReportRunController implements BatchRetryable
{
public static void main(Args _args)
{
    xx_myController controller;
    controller = new xx_myController();
    controller.parmArgs(_args);
    controller.parmReportName(ssrsReportStr(xx_myReport, Report));
    controller.parmDialogCaption("@xx:1231564");
    controller.parmLoadFromSysLastValue(true);
    controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    controller.parmShowDialog(true);

    controller.startOperation();
}
}

 
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,634 Most Valuable Professional on at
    You didn't tell the report to print to the archive. You can do something like this:
    SRSPrintDestinationSettings settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::Archive);
     
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,803 Super User 2026 Season 1 on at
    Hi @akshi,
     
    try this code :
     
    class xx_myController extends SrsReportRunController implements BatchRetryable
    {
    	public static void main(Args _args)
    	{
    		xx_myController controller;
    		SRSPrintDestinationSettings     settings;
    		controller = new xx_myController();
    		controller.parmArgs(_args);
    		controller.parmReportName(ssrsReportStr(xx_myReport, Report));
    		controller.parmDialogCaption("@xx:1231564");
    		controller.parmLoadFromSysLastValue(true);
    		controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    		controller.parmShowDialog(true);
    		
    		if(this.isInBatch())
    		{
    			settings = controller.parmReportContract().parmPrintSettings();
    			settings.printMediumType(SRSPrintMediumType::Archive);
    			settings.fileFormat(SRSReportFileFormat::PDF);
    			settings.fileName('ReportName.pdf');
    		}
    
    		controller.startOperation();
    	}
    }
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • akshi Profile Picture
    154 on at
    Hello 
    Thanks for your advises.
    I tried debugging in batch mode, but the debugging did not stop and the report was not saved in the print archive. When the batch screen was launched, it stopped at if, but when the batch was executed, Debut stopped after passing the DP class and the batch processing ended.
     
    class xx_myController extends SrsReportRunController implements BatchRetryable
    {
    	public static void main(Args _args)
    	{
    		xx_myController controller;
    		SRSPrintDestinationSettings     settings;
    		controller = new xx_myController();
    		controller.parmArgs(_args);
    		controller.parmReportName(ssrsReportStr(xx_myReport, Report));
    		controller.parmDialogCaption("@xx:1231564");
    		controller.parmLoadFromSysLastValue(true);
    		controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    		controller.parmShowDialog(true);
    		
    		if(controller.isInBatch())
    		{
    			settings = controller.parmReportContract().parmPrintSettings();
    			settings.printMediumType(SRSPrintMediumType::Archive);
    			settings.fileFormat(SRSReportFileFormat::PDF);
    			settings.fileName('ReportName.pdf');
    		}
    
    		controller.startOperation();
    	}
    }
     
  • Martin Dráb Profile Picture
    239,634 Most Valuable Professional on at
    Do you want to call main() from another batch process, or do you main() to schedule a batch? Mohamed's code is wrong in both cases.
     
    If your goal is creating a batch, calling isInBatch() in main() doesn't make sense. A batch task will be created in startOperation() and the batch won't ever call main().
     
    If you want to call main() from another batch, trying to show the dialog (parmShowDialog(true)) is wrong. There is no user to interact with the form.
     
    Regarding debugging, don't forget that batches are executed by batch.exe, not by issexpress. You need to attach the debugger to batch.exe.
  • akshi Profile Picture
    154 on at
    Hello Martin,
     
    Thanks for your advice.
    I debugged using batch.exe.
    I am expecting the following process.
    The parameters entered by the user from the batch dialog screen are obtained and the batch is executed. I would like to save it to the print archive when the batch is complete.
    Below is the standard batch screen. I am creating the same screen as this report. (Records to include filters are not included). In the current implementation, if batch mode is turned off, it is output to the screen, but when the batch is executed it is not saved to the print archive. If there is anything I should use as a reference please let me know.
     
  • Martin Dráb Profile Picture
    239,634 Most Valuable Professional on at
    Let's forget a batch for a moment. Does it get saved to a print archive when printed interactively? You didn't mention that, therefore I\m assuming it's not and the problem isn't actually specific to a batch. If so, you got confused by yourself by focusing on batches and you forgot to test the simpler case before testing the more complex scenario. You have a problem with print archive in all cases; it's not something it works interactively but not in batch.
     
    Please confirm what behaviour you observe in your environment. Also, tell us how you check whether the file is in the archive.
  • akshi Profile Picture
    154 on at
    The print archive is here: Common>Inquires>Print archive
    When run not in batch mode, it will be downloaded to downloads folder, not saved to the print archive. My requirement needs to be run in batch mode because it is a report of large amount of data. In the standard FO, if you run the report in batch mode, it will be saved in the print archive.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,803 Super User 2026 Season 1 on at
    Hi @akshi,
     
    I think you need to look in the report archive not in the print archive.
     
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • akshi Profile Picture
    154 on at
     
    I also checked the report archives but there were no reports there.
     
     

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 164 Super User 2026 Season 1

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 106 Super User 2026 Season 1

#3
Zain Mehmood Profile Picture

Zain Mehmood 89 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans