Geocortex Reporting allows users to generate reports that accept JSON data sources. This functionality can enhance system integrations and improves reporting processes! Additionally, it provides a means to dynamically supply JSON data to PDF reports so it can be interpreted at runtime.
This Geocortex Tech Tip will explain how to generate reports that accept JSON data. Further, it will demonstrate how to set up workflows that dynamically generate JSON and pass that data into Geocortex Reporting.
Hey everyone, my name is Patrick Fingler, and in this Tech Tip video, I’m going to highlight how you can generate reports that accept JSON data sources using Geocortex Reporting. This is a great method if you need to integrate with different systems or if you want to dynamically supply JSON to a PDF report and interpret those attributes at runtime. If that sounds interesting let’s dive in further!
Alright, so let’s get started! Here you can see I’ve got some sample JSON that I’ve created. This is just some JSON, including some work order features which are part of an Esri feature set.
If you scroll down here, you can see that raw JSON and when it looks like kind of formatted. You can see here we’ve got six “features”, or an array of features. And inside of a feature you can have multiple “attributes” as well as “geometry”, point geometry, associated to each feature. So, each feature is going to have its own list of attributes and so on.
Let’s say I have this JSON, and I want to now generate a report based on it. We’ll navigate to Geocortex Reporting. The first thing you want to confirm is that you’re using Geocortex Reporting 5.13 or greater because that’s the version of reporting where we introduced this capability.
If you navigate to data sources, you’ll click “Add Data Source”. This is where we can insert a JSON data source. We can connect to ArcGIS data sources, non-spatial databases, and now we’ve got the ability to connect to raw JSON.
So, here I’ll supply my data source name. I’ll call this my “Work Orders JSON Data Source” and now I can supply some raw JSON. Here you can see this is the structure of the JSON. Again, we’ve got an array of features, attributes and so on. I’ll eventually click save, I first just wanted to mention that you don’t need to have the underlying values of your JSON. Really all we need is the schema of the JSON in place. But, for testing purposes it is often quite nice to just have some sample JSON in place. So, I’m going to click “Save”.
And now that that’s saved, I’ve got a blank report. I can go ahead and click “Add Data Source”. And now I’ve got the ability to choose a “JSON” data source. We’ll click “Next”.
You can see these are some of the JSON data sources that I have available. I’m going to select my “Work Orders JSON Data Source” and you can see here that this kind of reviews the schema of that JSON. So here we can see we’ve got our “features” array and inside of that features array you’ve got “attributes”. These are all the attributes available, and these are all the “geometry”. You can choose what items you might want to include in your report. So, maybe I just want to generate a report that loops over this features array.
So, I’m going to go ahead and click “Finish” and we’ll see that that gets populated. Here I’ve got my “JSONDataSource1”, here I’ve got my “features” and then here I’ve got my “attributes” as well as my “geometry”. So, I’m going to go ahead and add these. Maybe I want to include the “objectid”, the “inspector” and the “template” for the work orders that were included in this JSON object.
I’m actually going to click delete, and I’m also going to add the “geometry”. I can see that this geometry is also contained within this feature. So, let’s add that as well.
You can see here this is going “attributes.objectid” and then also “geometry.x” and “geometry.y”. Because I have some sample JSON data within my data source, I can just click the “Preview” button and we should see six work orders coming from that underlying JSON object.
So, there you go, we can see we’ve got six work orders. These are the object ID’s, the inspector names, the work order type and the coordinates listed there.
Now this is a very simple example. How you actually implement this in practice is you’re typically going to want to have a workflow which is used to dynamically generate that JSON. Whether you’re integrating with a rest API and getting some JSON back, or if you want to manipulate some data using workflow, create some JSON and then pass that to a report, that typically would be done on the workflow side.
So, what I’ve done here is I’ve created a workflow in Geocortex Workflow that uses some of our Maximo custom activity packs. If you’ve licensed Geocortex Workflow, you can get these for free on our GitHub. I just want to show an example where we’re actually sending a web request to a rest API, we’re dynamically retrieving some JSON and then passing that to a report.
Let’s go ahead and run this. I’ll click “Start” and run it.
Let’s rerun this and clear our console and network tab. It’s going to ask me to log in. I’ll enter my credentials and click “Login”. Let’s just clear the console network tab again.
Here you can see we’re actually issuing a web request to Maximo and now we’re generating a report.
You can see that it’s all done generating; we can open this up and we can see we’ve got a report that has the top 50 work orders getting pulled from Maximo. A really basic report here. We’ve got those three attributes.
There are a few steps involved, but hopefully that helps you start dynamically passing your own JSON objects to Geocortex Reporting. I know a lot of customers have been waiting for this functionality, so hopefully that helps. Bye for now!
Want to learn more about building reports with Geocortex Reporting? Click the button below for more information on the capabilities of Geocortex Reporting.