ArcGIS Survey123: Smarter Forms with Survey123 Relevant Fields

ArcGIS Survey123: Smarter Forms with Survey123 Relevant Fields

We’ve already covered the difference between Survey123 Connect and the Web Designer, talked about why designing before you build is key, how keeping your XLS sheet organized can save your sanity, and geopoint/geocoding magic. Now, let’s look at some more magic: relevant fields!

I’ve been using relevant expressions in Survey123 for years, and at this point, they’re second nature. Whether I’m hiding fields that aren’t needed, ensuring users only see the questions that apply to them, or reducing errors by keeping forms streamlined - relevant expressions do the heavy lifting???♀? .

Let’s dive in!

How Relevant Fields Work

At their core, relevant fields in Survey123 use expressions to control when a question appears. This happens in the relevant column of your XLSForm. When the condition is met, the field is visible; if not, it stays hidden.

Another cool thing? Relevant fields work on groups and repeats. Instead of adding a relevant field for every attribute in a group, you can just use the relevant column in your XLSForm on the begin group line. This reduces the chance of error with your relevant attributes and helps keep things tidy, while still controlling visibility for grouped attributes.

Bread and Butter Expressions

  • Want to show a field only when a user selects a specific option? Use selected()
  • Need to display a question based on a numeric input? Use a comparison expression like ${attribute_name} > value

Examples:

  • Dropdown Selection - Only show the macro species attribute field, if 'yes' is selected for macros present: selected(${macro_benthos_present}, 'yes')
  • Numeric Condition - Only ask for riffle substrate details when the the water depth is less than 0.5 feet: ${water_depth} < 0.5
  • Multiple Conditions - Show an attribute field for invasive species only if vegetation is present and the percent cover is greater than 25%: selected(${vegetation_present}, 'Yes') and ${veg_cover} > 25

Relevant fields that are dependent on a value of a previous attribute

Debugging Relevant Expressions

When you're working with relevant expressions, you will need to debug, especially when your relevant expressions increase in complexity. Here are a few things to keep in mind:

  1. Check field names carefully - case sensitivity matters! A small typo or wrong case can cause a field to not show up.
  2. ALWAYS Use the Survey123 Connect preview to test your form in real-time. It helps you quickly spot if something’s off.
  3. Double-check dependencies if a field isn’t showing up. Maybe it’s hidden because of a condition you missed or misconfigured.
  4. Understand the syntax - if things aren’t working, it might be a small syntax error you’ve missed. A good grasp of how expressions should be structured is key.
  5. Use a code editor app (like PyCharm or Notepad++) - The color-coding, auto-complete, and visual grouping of parentheses and curly braces help immensely! Shoutout to Katie Clark, GISP for this pro tip circa a long time ago! I can't tell you how many times a rogue parenthesis has broken everything, and I went crying to Katie for help!

Want to learn more? Check out this post, and I suggest you bookmark it for later: Survey123 Tricks of the Trade: hidden, relevant and body::esri:visible. Also, make sure to check out the "Relevant Expression" sample in Survey123 Connect!

Try adding a relevant expressions to your next form and see how much cleaner it looks!

Next week we are going to look at some calculations in S123!


GIS You Later!


Pro Tip: Think of a temporary “debug” question in your form like a Python print() statement. It helps you see what’s going on behind the scenes. Add a note or text field that displays the value of a key controlling field. If something isn’t showing up as expected, this quick trick can reveal where your logic might be off!

Michelle Williams

Survey123 Jedi | HEALING OUR Survey123 trauma (GIS)??

1 周

The Force is strong with you. Keep preaching the good news.

要查看或添加评论,请登录

Megan Engel, GISP的更多文章