Inserting Dynamix AX 2012 SRSS PDF report into another database
-
21-02-2021 - |
Question
I need to insert a PDF report into a linked database upon generation in AX2012. When a user generates the report in AX, a copy needs to be inserted into another database. I am not sure if this is possible. If there are any URLs or links that can point me into the right direction, I would appreciate it.
Solution
I would not recommend storing BLOBs directly in another database. Save the data in an AX record first, then transfer it using SSIS or similar.
Update: I did not notice the SRSS part of you question, the following will only work for old style reports.
The first step is to generate the PDF file, which can be done like in this method, which returns a container to be saved later:
client container reportFileCreate(PurchReqQuickId _reqQuickId, Object caller, ReportName reportName)
{
MenuFunction mf;
ReportRun rr;
PrintJobSettings pjs;
Args args;
BinData data;
#File
FileName reportFile = WinAPI::getTempPath() + 'qr' + _reqQuickId + #pdf;
;
new FileIOPermission(reportFile, 'r').assert();
mf = new MenuFunction(reportName, MenuItemType::Output);
args = new args(caller);
args.record(this);
rr = mf.create(args);
rr.init();
rr.report().interactive(false);
rr.query().interactive(false);
pjs = rr.printJobSettings();
pjs.format(PrintFormat::PDF);
pjs.setTarget(PrintMedium::File);
pjs.fileName(reportFile);
pjs.outputToClient(false);
rr.run();
data = new BinData();
data.loadFile(reportFile);
WinAPI::deleteFile(reportFile);
return data.getData();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow