Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : 8f2T6Ul+rXpEESkY4atlIe
Supply chain | Supply Chain Management, Commerce
Suggested answer

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

Like (2) ShareShare
ReportReport
Posted on 25 Mar 2025 06:47:20 by 126
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();
}
}

 
  • akshi Profile Picture
    126 on 26 Mar 2025 at 00:54:42
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
     
    I also checked the report archives but there were no reports there.
     
     
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    19,089 Super User 2025 Season 1 on 25 Mar 2025 at 21:34:52
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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
    126 on 25 Mar 2025 at 13:29:59
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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.
  • Martin Dráb Profile Picture
    232,223 Most Valuable Professional on 25 Mar 2025 at 13:18:39
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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
    126 on 25 Mar 2025 at 12:55:15
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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
    232,223 Most Valuable Professional on 25 Mar 2025 at 12:18:10
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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
    126 on 25 Mar 2025 at 11:05:32
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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();
    	}
    }
     
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    19,089 Super User 2025 Season 1 on 25 Mar 2025 at 09:29:51
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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
  • Suggested answer
    Martin Dráb Profile Picture
    232,223 Most Valuable Professional on 25 Mar 2025 at 09:23:54
    How can I implement saving SSRS reports to a print archive after executing in batch mode?
    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);
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,325 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,223 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading started