Repeat Counts that are Conditional

09-19-2022 12:12 PM
New Contributor II


I am working on a survey that will eventually be public facing. There is a question “Are you closing a lane of traffic” that conditionally opens up a repeat section if the user answers ‘yes’.  If the answer is yes, at least one record is required in the repeat. The user should not be able to submit the survey with an answer of yes but have no repeats.

I set up a conditional query. It only engages when the user says yes to a closure, and uses the count function of a required field within the repeat to total the entries. The constraint on that field is greater than zero, so if activated and no records appear, the constraint message pops up.

This works as intended within the Survey123 Connect preview (image: connect_success). However, upon publishing, the web version starts with the repeat expanded if enabled (image: web_default) and then the user can hit the trash can to delete the record (image: web_delete). If deleted, the user can successfully answer ‘yes’ to the closure question and not input an entry - the error doesn't come up.

@Ismael @JamesT 

Any insight as to

  • Why the functionality in connect is not matching the web form, and
  • Any way to fix this problem?

Thanks so much.

0 Kudos
2 Replies
Occasional Contributor II

Looks like it is related to the known bug where Survey123 won't evaluate a field if a question is hidden or not relevant. This is a bug that's been around for years:

Seems like what is happening is that, when the first repeat instance is deleted, the repeat is becoming hidden. As soon as a question is hidden, Survey123 won't evaluate it for required or constraint.

There is a fairly simple work around: see the attached .xlsx sheet.

You'll notice that this only works because it forces the survey to make the the conditional query itself visible. By making the query visible, Survey123 evaluates it for constraints and requirements. As soon as you set that query to calculate [type], or if you set [appearance] to hidden, the problem remerges because the question is hidden.

This is a serious bug, and it's bit disappointing that it hasn't been addressed for several years.

New Contributor II

Interesting, thanks Lawrence. It's crazy to me that the hidden query (which is essentially how I deployed a workaround) functions in Survey123 Connect but then completely fails in the published web version.  Made things extra frustrating given I can't test until published. 

I appreciate your help. 

0 Kudos