Select to view content in your preferred language

required photos if any of a list of questions has a 'yes' in sections of a survey

475
3
09-13-2023 03:36 PM
CyndyJBresloff
New Contributor II

Hello, GIS'ers: 

I am fairly new to Survey123, and I've tried to find an answer to my question, but so far I have not.  I am creating a Survey123 app that is duplicating a lengthy inspection process.  The process has sections and the questions in the inspection sections are numerous.  I would like to, in each seection group of questions, have photos be required 'if there is a violation' (if any of the questions in that group have a 'yes'.)  I'm attempting to avoid having to have photos be conditionally required after every. single. question; as the form would be pretty tedious... I tried to implement this as, for example :

selected(${corrosion},"yes") or selected(${openvalves},"yes") or selected(${discoloration},"yes")

in the 'required' field for the image, but I get an error when updating the form.  Is this possible in the required field, and if so, what is the syntax?  

Tags (1)
0 Kudos
3 Replies
DougBrowning
MVP Esteemed Contributor

What you posted is correct.  Any expression that validates to true will work.  You will get a error because Excel has it set to a blank or yes drop down but the form will take the formula if you say ok and will work as you want.  Same issues as select_one when you add a list name.

Your other option could be to set required to yes then move this formula to the relevant and then it will not show the photo question at all.  But then the user cannot add any photo.  Up to you.

Hope that helps

abureaux
MVP Regular Contributor

@DougBrowningis correct, your logic is correct and will work.

I assume when you say "error", you mean that little green triangle in the top left of a cell? If you are referring to something else, there is likely something else going on.

abureaux_0-1694713234296.png

You can safely ignore that. It is because you entered something not in the official drop-down list. This is essentially an Excel data validation "error". NOTE: In older XLSX files, you may also get a pop-up warning from Excel if you enter a value that isn't in the drop-down. That pop-up was removed semi-recently.


There is a way to turn that off, but I don't generally recommend it. However, if you really want that triangle gone, do this:

1.Select the cell(s) you want to modify.

2. Data Tab

3. Data Validation

abureaux_2-1694713466532.png

4. Change Allow to Any value

5. Press OK

abureaux_3-1694713531766.png

6. Done. (Note: You may need to click into and then out of the cell for it to refresh).

abureaux_4-1694713580402.png

 

CyndyJBresloff
New Contributor II

Thank you, Doug, for the confirmation; I actually had an error that was not in the expression causing my issue; you helped me rule out an expression syntax problem.

And thanks, Abereaux, for clarification about those 'little green triangles' - I could not figure out why I had several in my XLS form, and I thought they were errors, and yet my survey still published..!