Many Geocortex customers use Survey123 to perform various offline data collection processes and need to include this information within PDF reports. Using Survey123 webhooks, you can now configure workflows that get triggered when a feature is collected or updated.
A great example of this process is to dynamically generate and email PDF reports to various stakeholders after a survey is submitted.
To best demonstrate this, Patrick will show you how to dynamically generate reports from Survey123 in this Geocortex Tech Tip.
“Hi, my name is Patrick Fingler and in this Tech Tip video, I’m going to show you how to dynamically generate reports from Survey123. Let’s dive in!
So here you can see I’ve launched Survey123 on my mobile device.
I’ve just created a really simple survey to perform a Work Order. So, I’m going to go ahead and
click Collect. The survey is going to retrieve my geolocation, I can enter my name as Patrick Fingler, specify the level of priority, we’ll say there’s low priority.
I’ve got some work order templates that I can use. I’m going to go ahead and select Maintain Tree and maybe we’ll say. “Needs to be trimmed” and let’s continue the survey and let’s upload an image.
So, I’m going to go ahead and take a photo and I’m just going to take a photo of my laptop here and pretty happy with that.
So, let’s submit this survey. What we’ve implemented is now when you send the survey and you have internet connectivity, we’ll then be able to generate a report.
In just a few moments, you’ll see the report gets generated and it actually sends an
email to the user who created the report or sorry who submitted the survey.
We’ll just give it a few more seconds and I should get an email soon.
Here we can see I’ve got an email report. Let’s open it up and here you can see if we zoom in, we
can see there’s my attachment we’ve also got a QR code as well and also just launch it as well on my laptop.
So, here you can see there’s also a QR code there.
Let’s go ahead and scan that QR code and what’s nice is in these reports, you can also include QR codes as well.
So, what this is going to do is it’s going to open up our Geocortex Mobile application and it’s going to highlight the work order that we just created. This is referencing an ArcGIS web map
and here you can see there’s my comments saying it needed to be trimmed and the attachment got included as well.
I’m gonna just stop sharing my phone and close my connection and let’s kind of review this again this particular report.
Here you can see a very basic report that I’ve configured here which essentially gets the some of the attributes that I entered with it went from Survey123.
So, my name you know the status the template and my comments and then we dynamically
created a QR code that will launch another third-party application and here we’ve included some attachments.
How do you essentially create this process using Geocortex technology?
The first step is in Survey123. On your survey, there’s going to be this Web Hooks tab. So, you’re going to want to navigate to settings and go to web hooks there, you’re going to click Add Web Hook, I’ve already done this.
Let’s edit this, we can see the status is On and essentially you have to direct or create a payload URL.
So, in order for you to perform this process you need to have Geocortex Workflow installed on premise.
So, all it needs to be installed on one of your internal web servers.
In this scenario I’ve installed Geocortex Workflow on this particular domain, so portal.geocortex and it’s authenticated with my ArcGIS Enterprise.
I’ve shared my workflow with everyone and here you can see this is the ID of my workflow.
So, you’re essentially going to construct this payload URL.
You’re going to essentially get the domain of your server Geocortex Workflow/ service/webhook/ survey123 and then this is going to be the ID of your workflow.
All of this, is this is where you can determine when this web hook gets triggered so when a new record submitted or when an existing record is edited and then also you can supply essentially, all of this you know information can get passed to the workflow and then you can decide to include that information in an email or you know you could do a variety of different options or capabilities with it.
So, let’s go to the underlying workflow.
Here let’s open up the workflow, you’re going to want to use this Get Workflow Inputs activity,
this is going to get all of these inputs from Survey123 and what I like to do for debugging
purposes is I like to kind of write this to just a JSON file in a temporary directory on the workflow
So, you can actually see all of the different inputs that Survey123 is providing you with. So
essentially what I’m doing is I’m just passing in, I’m using the getworkflowinputs.inputs and then Survey123 passes a body of JSON essentially.
So, we’re going to write that to a server and what that looks like is once that’s actually getting
written. Let me log into this machine, you can see here I’m writing it to this directory and it’s just a JSON file you can see it’s actually been reloaded because we just ran it and here, you’re going to see it’s got my attachments and information on it, it’s got you know, the inspector, my comments.
So, all of this information the feature you know the underlying attributes, the geometry, you know the ID’s of your and the names of your attachments, you know the token information, your
username and email information for based on the user who’s running it.
All of this is information that you can use inside of your workflows.
So, in my scenario, the only things that i was grabbing was the object UD as well as the email of the user but you could do a variety of different branching, you know if it’s this particular user or they’ve assigned it to this particular field worker then we’re going to email it to that field worker or that group of field workers and so on.
This is really handy when you’re wanting to debug your workflow.
So, let’s go ahead and continue. So, because that’s just a JSON file, what you can do is you can parse that and that will turn it into like a JSON object rather than just string, so that you can start actually retrieving the values from that text document.
So here I’m essentially, I’m getting the parsing that JSON and then I’m getting the user info and the email from that.
So again, if we go back here and open that up and scroll down to the bottom there’s a property here called User Info and then I’m getting the email of that user and then similarly I’m also getting the object ID of the feature.
So, I’m getting the feature the result of the feature and then the object ID which I believe is somewhere near the top here, if we scroll up there’s results and object ID and i believe that’s
contained within this feature object.
So, let’s continue on.
So, once you have the object ID, I can then run a report.
So, I’m just going to generate a report based on that features object ID. This is going to be my report URL for Geocortex Reporting I can then download that report.
So, here I’m essentially going to this is, so we can add it as an attachment to an email.
So, I’m just going to pass the output of this report to my web request.
I’m going to have it return a blob and then I’m going to supply that content to this Create Email Attachment activity, I’m specifying that it’s a PDF, you could give it whatever file name that you want and then here I’m using the Send Email Activity to essentially dynamically send an email to whoever submitted the survey and then here I can supply whatever information that I want as well as any attachments that I want.
That’s essentially all the logic used to dynamically generate these reports.
Now in the back end we’re using the Geocortex Reporting Designer to build out these underlying report templates which provides a really intuitive and easy interface for generating reports that again can be dynamically generated from Survey123 which you saw but these reports can also be generated from Web AppBuilder or other ArcGIS or Geocortex applications.
I hope that was informative, that is essentially how you can dynamically generate reports from Survey123! Bye for now.”
Find out more about how Geocortex Reporting simplifies reporting for your ArcGIS Web AppBuilder and Geocortex applications by clicking the link below.