Referencing Attachments in Survey123 Web App using JavaScript

476
2
Jump to solution
03-24-2023 10:31 AM
ShawnHarris_CAR
New Contributor II

Our team would like to explore leveraging computer vision tools in our S123 web app data collection process. This would involve the user uploading attachments into the survey and receiving feedback from the computer vision tool before submitting the survey. We envision using the JavaScript extension within S123 Connect to feed the image uploaded into the survey to a computer vision tool we have access to and display the output of the tool to the user. For example, the user uploads a picture of a yellow fire hydrant to the survey and the feedback says "This is a yellow fire hydrant, please check you are in the right location. We are looking for a blue fire hydrant." This would be prior to submitting the survey.

However, we're not clear how to access the photo using a JS script that has been uploaded to a survey prior to submitting the survey. Any ideas?

@JamesTedrick - can see your creativity here 🙂

1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello @ShawnHarris_CAR

Unfortunately, this workflow falls under the inability to access local files limitation in JavaScript functions. If you provide a JavaScript function an input of an image question the function will receive the image name instead of the actual image. 

Since you plan on using the web app to collect data, you may be able to embed the survey in a web page and use the web app JavaScript API to extract the base64 image and call a JavaScript file in your web page to upload the image to the computer vision tool. 

Thank you,
Zach

View solution in original post

0 Kudos
2 Replies
ZacharySutherby
Esri Regular Contributor

Hello @ShawnHarris_CAR

Unfortunately, this workflow falls under the inability to access local files limitation in JavaScript functions. If you provide a JavaScript function an input of an image question the function will receive the image name instead of the actual image. 

Since you plan on using the web app to collect data, you may be able to embed the survey in a web page and use the web app JavaScript API to extract the base64 image and call a JavaScript file in your web page to upload the image to the computer vision tool. 

Thank you,
Zach
0 Kudos
ShawnHarris_CAR
New Contributor II

 

Hey Zach,

Thanks for the reply! This is really useful. We'll keep thinking and reach out if we start to build this capability. 

Shawn

0 Kudos