Setting related Reports Datasource or importing a report rptx

226
2
Jump to solution
03-21-2022 05:54 AM
PierreMasson
New Contributor III

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:

  • Include the reports in a project template so the reports will be part of any new project
  • We created a button in our addin, that create a copy of that report, sets the report datasource to the current GDB used by the user and export it to PDF.

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?

  • How to set related report datasource of a Report object?
  • How to import a rptx file programmatically?

Thank you

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GintautasKmieliauskas
Regular Contributor II

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

View solution in original post

2 Replies
GintautasKmieliauskas
Regular Contributor II

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));
PierreMasson
New Contributor III

wow so easy, thank you!

 

0 Kudos