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 :
Finance | Project Operations, Human Resources, ...
Answered

SSRS report not downloading in specified path in print settings. taking default browser downloads

(4) ShareShare
ReportReport
Posted on by 36
Im trying with following runnable job but report generated through this is downloading at browser specified path. Not the path i given in the code. below is the code im using. Let me know if im missing any part?
 
public static void main(Args _args)
{
    HallmarkingIssRcvTable hallMarkingRecord;
    SrsReportRunController reportController = new SrsReportRunController();
    IssueforHallmarkingVoucherContract reportDataContract = new IssueforHallmarkingVoucherContract();
    SRSPrintDestinationSettings printSettings;
    FileName filename;
    HallmarkingNo hallMarkingNo = '10Dckl000059955';  
    str directoryPath = @"C:\Temp\Reports\";  // Ensure this path is valid and accessible
    // Fetch the hallmarking record
    hallMarkingRecord = HallmarkingIssRcvTable::find(hallMarkingNo);
    if (hallMarkingRecord)
    {
        // Ensure the directory exists
        if (!WinAPI::pathExists(directoryPath))
        {
            WinAPI::createDirectoryPath(directoryPath);
        }
        // Set the filename for the output PDF
        filename = strFmt('%1%2%3', directoryPath, hallMarkingNo, ".pdf");
        // Configure the report controller
        reportController.parmReportName(ssrsReportStr(IssueForHallmarkingVoucherReport, Report)); 
        reportController.parmShowDialog(false);
        // Set up the report data contract with necessary parameters
        reportDataContract.parmHallmarkingNo(hallMarkingNo);
        reportController.parmReportContract().parmRdpContract(reportDataContract);
        // Configure print settings
        printSettings = reportController.parmReportContract().parmPrintSettings();
        printSettings.printMediumType(SRSPrintMediumType::File);
        printSettings.fileFormat(SRSReportFileFormat::PDF);
        printSettings.overwriteFile(true);
        printSettings.fileName(filename);
        // Set the configured print settings back to the controller
        reportController.parmReportContract().parmPrintSettings(printSettings);
        try
        {
            // Start the report operation
            reportController.startOperation();
            info("Report generation initiated.");
            // Check if the file was created
            if (System.IO.File::Exists(filename))
            {
                info("Report file successfully created: " + filename);
            }
            else
            {
                error("Report file was not created.");
            }
        }
        catch (Exception::Error)
        {
            error("An error occurred while generating the report.");
        }
    }
    else
    {
        error("Hallmarking record not found for the given number.");
    }
}
Categories:
I have the same question (0)
  • Verified answer
    Jonas "Jones" Melgaard Profile Picture
    5,010 Most Valuable Professional on at
    I have moved your question to the Finance forum, since this looks a lot like D365 F&O / Dynamics AX code.
     
     
    F&O has no knowledge about the local file system, since it's a cloud product.
    If you want to store the reports in a specific path, you need to investigate another way to store the file.
     

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

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans