Survey123 smart forms let you record signatures, photos, annotated images and upload documents into ArcGIS. All of these are stored in ArcGIS as 'attachments'. Microsoft Automate includes a Survey123 connector that helps you access ArcGIS attachments submitted through a smart form.
This blog provides guidance for two common scenarios involving Survey123 attachments and Microsoft Power Automate:
It is assumed you are already familiar with task automation using Survey123 and Microsoft Power Automate. If so, get started by publishing a survey with an image, signature, file or some other question that uses ArcGIS attachments. Then log into Office 365 and create a new Automated flow with the Survey123 trigger. Follow the instructions below to experiment first hand with Survey123 attachments in Power Automate.
To work with ArcGIS attachments in Power Automate, we are going to use the HTTP module in Power Automate. Through this module we will query your survey's layer using the ArcGIS REST API. Now, for these queries to work, you first need to make sure that query capabilities are enabled in your survey's layer.
The easiest way to enable queries in your survey layer is though the Collaborate tab in the Survey123 website, although you can also do it manually through the item details page of your survey's layer.
Survey123 attachments are modeled as an array. In Microsoft Power Automate, you can create an array variable and populate it with Survey123 attachments. Later you can include that array variable in your email.
Immediately after your Survey123 trigger, add the Initialize variable action. We will populate this variable later with the attachments from your survey. Make sure you set the action Type to Array and set a descriptive name. Leave the initial value empty.
Next, add an HTTP action. This will help us download the attachments. Set the Method to POST. For the URI, you will use the Dynamic content dialog and select the feature attachment URL for your question. In my case, the question with attachments in my survey is called photo, so the dynamic content is feature attachments photo URL.
If you are working with a survey that is shared privately, you will also need to add your token as a query parameter. You can get a valid token from the dynamic content dialog (Portal Info Token).
Survey123 attachments URLs are modeled as an array because a single question in Survey123 can be used
to capture one or many attachments. Microsoft Automate will recognize your photo URL content as
an array and add an Apply to each block automatically.
Immediately after your HTTP module, add an Append to array variable action.
{
"ContentBytes": <Your HTTP action Body goes here. Build using an Expression>,
"Name":<Your feature attachments name goes here. Get from Dynamic Content>
}
Make sure you set your JSON value accurately. Do not forget the commas, curly brackets and other things that make JSON be JSON... Do not forget the comma right after the Body Content!
Add a new Step to send an email.
The key to setting up the Send an email action is to open the Advanced options panel and click the Switch to input entire array icon.
You will now be able to use the Dynamic content dialog to select the array variable you setup at the beginning of the flow.
Next we will have a look at another common scenario where you might want to backup your files, or host them outside ArcGIS so they can be used with other third party systems.
If you want to upload your attachments into Microsoft One Drive, for example, you can use the Upload file from URL action. For the Source URL property, select from the Dynamic content dialog the feature attachments URL array for the appropriate question in your survey. Remember that if working against a private survey you will also need to add your token to the url (?token=[Portal Info Token]). An apply to each block will be added automatically for you. Now all you need to do is to select the Destination File Path for your file. You can select an existing folder, or even create a new one.
In the example above, I set the Destination File Path using one of the questions in my survey. The value of my question determines the directory in OneDrive where the file will be stored. If the folder exists, it will use it. Otherwise, it will create a new one. This is an interesting concept, as it helps organizing files nicely: by ZIP
code, by case ID, by field team, etc.
A similar approach can be used to upload files into SharePoint, Google Drive or Microsoft Azure File Storage
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.