Hi, we have reports that will be included in our Addin. The datasource of those report will need to change base on the GDB the user is working with.
So here is what we did:
This does not work. Expected behavior according to this: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Reports#subreport-datasource
So when setting the datasource on the main report, the exported report shows no related reports at all. On another report, the related reports are showing but linked to the datasource hard coded in the related report. It's not changing the subreport datasource.
So I export that report to .rptx (which is json). I edited that json and replace the datasources of the subreports to the right database (the same has the main report) Then I reimport that rptx in my project and when I generate the PDF, all the data is showing fine.
So setting the datasource of the report does not seem to be always propagating the datasource to the related reports.
Now I wanted to maybe include the rptx files in our addin and when the user want to generate the report I would set all datasources in the json file, import the report (rptx) in the project, then generate the PDF. There is a CIMReport object that can load the json file to do that. But what I can't find is how to import a rptx in my project programmatically.
Can someone help me answer one of those 2 quastions please?
Thank you
Solved! Go to Solution.
Hi,
About how to import a rptx file programatically. Have you tried Project AddItem method?
var reportToAdd = ItemFactory.Instance.Create(pathToRPTXFile);
QueuedTask.Run(() => Project.Current.AddItem(reportToAdd as IProjectItem));
Hi,
About how to import a rptx file programatically. Have you tried Project AddItem method?
var reportToAdd = ItemFactory.Instance.Create(pathToRPTXFile);
QueuedTask.Run(() => Project.Current.AddItem(reportToAdd as IProjectItem));
wow so easy, thank you!