Survey123 Picture Attachments to Survey Questions

2839
7
Jump to solution
06-10-2021 09:19 AM
JoelClark2
New Contributor III

We recently recreated a Survey123 survey in Portal for ArcGIS. The survey has 2 "picture" questions and 1 "signature" question.


The survey was previously in AGOL, but I downloaded the feature service including the attachments and loaded these records into the survey feature service hosted in Portal.


The feature service in Portal has the attachments, and the attachments can be seen in the feature service data tab, but the Survey123 form is not "aware" that the attachments go with each of the three survey questions. For instance when viewing the survey in edit mode the three questions show no image, and when generating a Word Doc report the picture attachments are not shown for the questions.


What is the mechanism by which Survey123 relates a question to an attachment file so I can resolve this?

0 Kudos
1 Solution

Accepted Solutions
JoelClark2
New Contributor III

For future readers of this question, I found the answer.

Inside the attachments table in the Portal/AGOL backend is a field called "KEYWORDS". Set the value of this field to the name of the survey question, and the image will then be shown as the answer to the survey question.

However, in Portal or AGOL, you do not have access directly to the attachments table. There's two workarounds. Option 1. You can export and download the feature service item as a File GDB. Make the edits (this must be done in ArcGIS Pro) to the downloaded attachments table KEYWORDS field and share to Portal/AGOL and overwrite the existing feature service. Option 2. You can utilize code and the ArcGIS Server REST API to download all the attachments, delete the attachments from the feature service, and re-upload the attachments with the proper KEYWORDS. In the "addAttachment" REST operation there's a parameter called "keywords" that allows for this. https://developers.arcgis.com/rest/services-reference/enterprise/add-attachment.htm

Thanks!

View solution in original post

7 Replies
Strahanjen
Occasional Contributor II

Hi Joel,

While I'm new to this and don't have a direct answer to your question, here's an approach for copying your feature service from AGOL to Portal that I think will make an exact clone and keep all of the relationships intact. I use this approach when I need to clone a Feature Service, and it works a better than downloading an export and building the service from that. 

https://support.esri.com/en/technical-article/000022252

 

0 Kudos
RosemaryHatch
New Contributor III

From what I could find when we had this issue, using Portal prior to 10.8.1 does not allow you to tie the images back to the question (we ended up having to do the Survey in AGOL).

https://doc.arcgis.com/en/survey123/browser/analyze-results/knownissuesanalyzeresults.htm

 

0 Kudos
JoelClark2
New Contributor III

We are using Portal 10.8.1

0 Kudos
JoelClark2
New Contributor III

For future readers of this question, I found the answer.

Inside the attachments table in the Portal/AGOL backend is a field called "KEYWORDS". Set the value of this field to the name of the survey question, and the image will then be shown as the answer to the survey question.

However, in Portal or AGOL, you do not have access directly to the attachments table. There's two workarounds. Option 1. You can export and download the feature service item as a File GDB. Make the edits (this must be done in ArcGIS Pro) to the downloaded attachments table KEYWORDS field and share to Portal/AGOL and overwrite the existing feature service. Option 2. You can utilize code and the ArcGIS Server REST API to download all the attachments, delete the attachments from the feature service, and re-upload the attachments with the proper KEYWORDS. In the "addAttachment" REST operation there's a parameter called "keywords" that allows for this. https://developers.arcgis.com/rest/services-reference/enterprise/add-attachment.htm

Thanks!

ahargreaves_FW
Occasional Contributor III

@JoelClark2 thanks for this insight. I was having a similar issue whereby I am using a referral URL for a survey published within Enterprise 10.9.1. The existing FeatureService (URL) has attachments enabled. Like your original issue I could not see these attachments when viewing records via a URL such as:

https://survey123.arcgis.com/share/9XXXXXXXXXXXXXXXXXd?portalUrl=https://myEnterpriseURL.org/portal&...

I did some testing just now following your steps. Here’s what I did:

  1. Recreated a new S123 directly from the referral FS URL, so it remade itself in the exact same format.
  2. Before publishing I removed the referral URL, so it published itself with a new hosted FS that would be the exact same schema as our existing FS.
  3. Added a new record with a photo to this new survey.
  4. Visited the URL for new record: https://survey123.arcgis.com/share/5xxxxxxxxxxxxxxxx9?mode=view&globalId=fcb58472-2585-4d3a-81f4-aab...
  5. I could edit the record and see the image.
  6. Added my new FS made in #2 above to a fGDB, downloaded and compared the attachment table to our existing one. Unlike as described in this post there was initially no difference at all…

ahargreaves_FW_0-1702482845405.pngahargreaves_FW_1-1702482906004.png

In order the get this working I had to then:

  1. Use the 'Upgrade Attachments' GP tool within Pro on the FeatureClass (not the attachment table but the main FeatureClass) to add the KEYWORD and EXIF fields.
  2. For those existing records I calc'd the KEYWORD to be the name of the S123 question
  3. I then also set the DEFAULT value for KEYWORD to also be the same name of the S123 question. This didn't work for some reason. 
  4. Instead I set up an attribute rule to do the same thing. This works.
  5. Republished.

Now I can see images on the end of URLs!

ahargreaves_FW_0-1702496300077.png

 

Huge thanks!

0 Kudos
MicZatorsky_AEC
Occasional Contributor III

WRT 

Option 1. You can export and download the feature service item as a File GDB. Make the edits (this must be done in ArcGIS Pro) to the downloaded attachments table KEYWORDS field...

I have exported my AGOL-hosted Survey123 FGB, and in the attachments table there are no KEYWORDS and EXIFINFO fields as shown in your screenshot.  Where did they come from?   My survey is 12 months old, is this from a newer release of Surevy123, or is it a Portal-only thing?

Thanks

0 Kudos
JoelClark2
New Contributor III

My understanding from discussing with Esri support is that picture-question editing is recent since Portal version 10.8.1, though it's been in AGOL for some time.