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

It does not copy the ssrs report in D365FO to the path I want! X++

(3) ShareShare
ReportReport
Posted on by 44
Hi,

In the ssrs report I made in On-Prem D365FO, no file is created in the path in the parameter "settings.fileName(fullpath);". The folder permissions are read and write for everyone.
But when I run the code below via the browser with the runnable class, it copies it to the Downloads folder.
str result = al.getFile(testRecId, "", "", "Notu", "ABC123");
 
PU: 10.0.41 (10.0.2015.110)
Thanks,
    public str getFile(RecId _recId, HcmPersonnelNumberId _first, HcmPersonnelNumberId _second, str1260 _not, packingSlipID _irsNO)
    {
        str result;
        Args args = new Args();
        WHSShipmentTable whsTable;
        try
        {
            select whsTable where whsTable.RecId == _recId;

            args.record(whsTable);            
            str filePath = @"c:\Temp";
            str fileName = "File_" + _irsNO + ".pdf";
            str fullpath = System.IO.Path::Combine(filePath, fileName);
        
            if (!WinAPI::folderExists(filePath))
            {
                if (!WinAPI::createDirectory(filePath))
                {
                    throw error("Error: " + filePath);
                }
            }
            FileController controller = new FileController();
            controller.parmReportName(ssrsReportStr(KPSIplikCekiListesiReport, Report));
            controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
            controller.parmShowDialog(false);
            controller.parmArgs(args);
            controller.parmShowReportViewerParameters(false);
            //controller.parmDialogCaption("Deneme");
            //controller.parmInBatch(false);
            
            FileContract contract = new FileContract();
            contract.parmRecId(_recId);
            contract.parmBirinciImza(_first);
            contract.parmIkinciImza(_second);
            contract.parmNot(_not);
            controller.parmReportContract().parmRdpContract(contract);
            
            SRSPrintDestinationSettings settings = new SRSPrintDestinationSettings();
            settings.printMediumType(SRSPrintMediumType::File);
            settings.fileFormat(SRSReportFileFormat::PDF);
            settings.overwriteFile(true);
            settings.fileName(fullpath);
            controller.parmReportContract().parmPrintSettings(settings);            
            
            SysOperationstartResult sonuc = controller.startOperation();
            if (WinAPI::fileExists(fullpath))
            {
                using (System.IO.Stream stream = System.IO.File::OpenRead(fullpath))
                {
                    File::SendFileToUser(stream, "File_" + _irsNO + ".pdf");
                }
                result = strFmt("Report generation successful: %1", fullpath);
            }
            else
            {
                result = "An error occurred while generating the report::";
            }
        }
        catch (Exception::Error)
        {
            result = "An error occurred while generating the report:: ";
        }
        catch (Exception::CLRError)
        {
            result = "CLR eroor: " + CLRInterop::getLastException().ToString();
        }

        return result;
    }
 
 
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    236,499 Most Valuable Professional on at
    It does not copy the ssrs report in D365FO to the path I want! X++
    Okay, when you call getFile() from a runnable class, it works. But how do you call it when it doesn't work? Is it executed in batch, for instance?
     
    Moved from Integration, Dataverse, and general topics forum to Finance | Project Operations, Human Resources, AX, GP, SL forum.
  • Oguzhan Profile Picture
    44 on at
    It does not copy the ssrs report in D365FO to the path I want! X++
    By user request, for example, by a button click
  • Martin Dráb Profile Picture
    236,499 Most Valuable Professional on at
    It does not copy the ssrs report in D365FO to the path I want! X++
    Does the button call exactly the same code as your runnable class?
     
    What did you find when you debugged the code?
  • Oguzhan Profile Picture
    44 on at
    It does not copy the ssrs report in D365FO to the path I want! X++
    Martin, thank you for your interest.
    I managed to get the problem as a byte array instead of saving it to a physical path.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,933

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 793 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 537 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans