Select to view content in your preferred language

GeoDev Webinar: Working with Custom JavaScript Functions in ArcGIS Survey123

1160
0
07-02-2021 12:04 PM
AmyNiessen
Esri Regular Contributor
0 0 1,160

On Wednesday, June 16th, we hosted a GeoDev Webinar, “Working with Custom JavaScript Functions in ArcGIS Survey123”. Ismael Chivite, Senior Product Manager, and Travis Butcher, Professional Services, presented this webinar that helped developers learn how to take their ArcGIS Survey123 smart form logic to the next level using their own JavaScript functions.

With over 400 developers in attendance, we received a good number of questions. Most of them, you can find in the recording of the webinar; however, we have captured the ones we were unable to get to during the webinar below.

Q: Where can I get started with custom JS functions in Survey123?

A: Here are three useful links:

Q: Can custom JS functions work in the Survey123 web app?

A: Yes, custom JS functions are supported in both the web and field Survey123 apps.

Q: Can custom JS functions work while offline?

A: It depends on what your custom JS function does. If your code makes use of external web services, your JS function will not work while offline.

Q: Can I use custom JS functions in a public survey?

A: No. Due to security considerations, the execution of custom JS functions is disabled in public surveys.

Q: Does Esri have any plans to support custom JS functions in public surveys?

A: So far, security reviews advise against enabling custom JS functions in public surveys. Esri will not enable execution of custom JS functions in public surveys if they compromise security.

Q: When would I use a custom JS function instead of a webhook?

A: The “when” and “what” will help define if we should use a custom JS function or a webhook:

  • When: A custom JS function is invoked while the form is being completed by the end user. A webhook is executed after the form has been submitted. You want to use a custom JS function if you want the end user to have immediate feedback while completing the form. For example, to run a validation rule or to calculate a value that must be presented to the user or used somewhere else in the form. Custom JS functions can be invoked multiple times while the form is completed by the user. For example, if you invoke a JS function as part of the calculation of a question, your JS function will be invoked anytime a question used by your calculation changes.
  • What: Custom JS functions are best used to perform short and simple operations, for example, to do a quick query against a feature layer, to process elements within a repeat, parse the output of a QR code, etc. If you need to automate notifications or integrate with other business systems, webhooks will be a better choice as tools like Microsoft Power Automate and Integromat will do that job easier.

Q: What is the best way to store the latitude-longitude vales of a geopoint question using custom JS functions?

A: The use of a custom JS function is not necessary to extract and store the latitude/longitude values of a geopoint question. Check this blog post for details.

Q: How can I assign a preferred IDE to use with Survey123 Connect?

A: Simply configure your operating system to open .js files with your favorite IDE.  Once this is done, Survey123 Connect will let you open your Survey123 custom JS files from your IDE.

Q: When does a custom JS function get invoked?

A: Depends on where you insert the pulldata(“@javascript”) call. For example, if you use your JS function in a calculation, Survey123 will invoke your code any time the value of your question needs to be re-calculated.

Q: Can I use a custom JS function to populate a list of choices?

A: No. However, you can use the search appearance to populate a list from a feature layer query. Check the details in the Survey123 Early Adopter Community.

Q: If my JS function outputs JSON, can I parse that JSON using XLSForm?

A: Yes. Using pulldata(“@json”).

Q: Where can I find more details about using webpack.js.org in my custom JS functions?

A: Watch this YouTube video.

 

If you were not able to catch this webinar, no problem! We have a recording of it, as well as the slides that you can review.

Recording: https://youtu.be/_AS7EgSLrF8

Slides: See attached

We have more ArcGIS Survey123 webinars in the month of June and will follow each one up with a blog post. For more webinars coming, please see our GeoDev events page.