A powerful benefit to Geocortex Essentials 5-Series products are their ability to combine with and supplement one another, further enhancing the way you build your web mapping applications and the data you’re able to display.
When it comes to reports, normally you’re usually dealing with one layer of data. But sometimes dealing with things like environmental impact or site suitability reports, it can be necessary to report on multiple layers at the same time.
In this week’s Geocortex Tech Tip, we’ll explore how to use Geocortex Workflow and Geocortex Reporting to produce a report that contains data from several different layers.
Video Transcript:
“Hi, I’m Ryan. Today I’d like to show you how you can combine Workflow 5 and Reporting 5 to create a report that includes data from multiple ArcGIS layers at the same time.
Let’s see how that’s done!
To set up for this, I ran the layer report wizard and you can get to it from the file new menu, and I selected the ambulance’s layer from this ArcGIS feature service and what I get is a report that’s bound to that layer and set up a perimeter, things like that (I also just updated the title).
This is a run over report at this point; the next thing I did was I created a workflow to run that report. You can use the run report activity and I select from the toolbox, you can provide the URL to your report, which of course, you can get from the info tab in report designer, and I’ve supplied some feature IDs.
So if you’ve used to layer report wizard, its expecting some feature IDs to be passed, this is the object IDs.
Here’s a JavaScript expression, it’s injecting a couple of them.
Finally, I’ve used the display form activity to present the output of that report. This report activity is going to spit out an href value which is the URL to download the report.
Here, I’m just using a load event of a text element to provide some markdown that’s going to create a hyperlink.
There’s a few ways to do this, but this is how I’ve set this up.
Let’s actually just run this and see that it works. I’m going to run in the sandbox. That’s going to run that report and the form will appear when the report is done.
There! I have a workflow running a report, passing in a couple of values and then the report runs and produces whatever the report output is.
Okay, so that’s our set up.
Now, what we want to do today is bring in multiple data sources. Running a report with one data source – okay, everybody can do that, but let’s pull in another layer and have two sections of results in this report.
I’m going to try and pull in this fire layer. Ultimately, what I want is that I want it kind of represented like this detail band with a list of available fields. I want two of these sections, one for the ambulances, one for the fire.
What we’re going to do can do, it might sound counterintuitive, but I’m going to clear out the data source of this report.
By default, this report is bound to this ambulances data source and if I select the top-level report itself, I can just tell the report that you don’t actually have a data source.
I’ve removed everything from the detail band, and I’m just going to collapse, because I’m not going to need this detail band.
Now on the report, what I’m going to do is I’m going to add a new detail band, sort of the special kind of detail band, but it allows me to select it and pick a data source for it.
I’ll select RedlandsEmergencyVehicles and the ambulances layer.
Now, I’ve got a detail band that specifically bound to an ambulance layer. What this lets me to is I can drag in the specific fields that I’d like to see in here.
What we’re going to do is — instead of just having this ambulance layer — we’re going to go up to the top-level catalog and we’re going to add another query, and I’m going to define a connection to this fire table, which it’s going to suggest, and I’ll select all the fields.
Now, I have two data sources at my disposal. What I’ll do is I’m going to add another one of these detail bands.
So, I’ve got two detail bands. I’m going to take the second one and I’ve got to tell it, that its data source is the fire table. I can do the same thing, or I can drag in the fire records that I want, and there we go! I’ve got my ambulance data, my fire data.
There are a couple other things we can do here, if we want a nice little header to say this is the fire data and this is the ambulance data. We can add a report header band that actually just adds it to this detail section.
I can put in a label here (this is my ambulance data), I’m going to make that bold, removing any extra space here, and I’ll do the same thing and add a report header to the second one. I got my fire section, and actually we might even want to do something like add a separator. You could just add a line, and I’ll just remove this extra space.
There’s still a critical step that we do need to do, we need to tell this fire data source how to perform its query, because right now it’s just going to query every record in the database which is not what we want. We’re going to want a parameter.
If we go back to the fields list here, we already have a parameter that was generated for us for the feature IDs.
This parameter, it’s a multi value number, so a list of object IDs. We want the same thing.
I’m just going to add another one. I’m going to call this fire IDs, it’s going to be a multivalued number. If I use object IDs, I can put them into the values list here.
Now the report is accepting the second perimeter called fire IDs. We just need to use that in query. If I select the fire data source, I can modify its query.
The way we do this is through a filter, and we want to select that it’s going to be a condition, where the fire object IDs are any value from a parameter.
I’ve just got to create any old name will do for this parameter.
When we complete the wizard, it’s going to ask us where we want that value to come from and rather than just being a type number, we’re going to use an expression, and this is going to allow us to pull that value from the input parameter from the report itself.
Now if we run the report, it should be asking us for two parameters and if I just go and grab a couple of object IDs, there we now have a report, it’s got the ambulance section, two rows of ambulance data, another section for the fire data, and two rows of fire related records
The report is now working. I’m going to need to save that. Then we are going to update our workflow to be able to call this.
So if I go back to the run report activity, right now we can see that this is passing feature IDs, it’ll also accept an arbitrary additional object that defines any other parameters that we might want.
What we need to pass in here, is an object that passes fire IDs and an array of numbers.
I’ll just hard-code. I’ll grab a different, I’ll make sure this is the fire layer. I’ll pass two different values, of course this fire IDs value needs to match the name of this parameter which looks like it does.
As many parameters as you have, you can keep passing more of these things in, so I’m defining an object with fire IDs property; the value is an array of integers and that should be enough!
I’ll go back to my sandbox and run this again. Download the report, and of course we get different data here, but again we can see we’ve got our values coming in right out of the live data from two completely different ArcGIS layers.
You can follow the same pattern with an ArcGIS layer in a SQL database, it all works really well.
The exciting part of all this, is once you got that report set up, you can craft your workflow.
Obviously, we don’t want to hard-code a list of IDs, but you would use the power of Geocortex Workflow to ask your user the right question, so that you are gathering the right object IDs, which might mean you’re doing queries, it might be you’re presenting forms with autocomplete lookups, but your workflow can control that, and then all we need to do is pass in one or more lists of IDs as parameters to that report and the user could download it.”
Find out more about how Geocortex Reporting simplifies reporting for your Web AppBuilder for ArcGIS® and Geocortex applications by clicking the link below.