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;
}