Select to view content in your preferred language

Required Fields Not Enforced in Automatically-created Repeats

88
3
Jump to solution
Friday
NickNuebel
Occasional Contributor

I have a survey123 form organized as follows:

  1. Select affected road parts (select multiple)
  2. Repeat: affected road part details. Each repeat record contains multiple required fields related to the details of the road part’s issues.

Each affected road part selected in step 1 automatically creates a repeat record for itself in part 2.

I’ve run into a bug (?) where some automatically-created repeats don’t enforce required fields until the user opens the repeat. The first repeat, which is open by default, enforces required fields. Subsequent repeats, which are not automatically-opened and require the user to manually page over to them, do not have their required fields enforced. This leads to situations where the user selects two road parts, fills out the required fields in the first repeat record, doesn’t open the second repeat, and then submits the form with required fields unanswered in the second repeat record.

As a workaround, I added a hidden field to each repeat that is equal to 1 after the first field of the repeat is filled out. Then, outside of the repeat, I created a checksum field that sums the values from the hidden repeat field. Finally, I added field that compares the number of selected road parts with the checksum field. The comparison field has a constraint that prevents the form from being submitted unless the comparison field is satisfied that the checksum and selected road parts fields are equal. In theory, this should prevent form submission until all repeats have been visited, which in turn should ensure that all required fields within each repeat have been filled out.

This looks like it should work, but it doesn't. This whole setup is buggy. It works in Survey123 Connect. It does NOT work in the Survey123 app (android, v3.24.22). Evidently there is some bug that prevents the final comparison field from always correctly evaluating when the two fields match; it only works intermittently and it’s not clear what circumstances cause it to fail. It fails more often than it works. The comparison field will re-evaluate the expression at odd times, changing its mind about whether 2 equals 2 (I’ve checked with experts and been assured that it does). For example, adding a photo attachment-- or even opening a previously attached photo—will sometimes make the comparison field’s expression re-evaluate from true to false without any change in the underlying values.

Nothing I’ve tried has worked. I’ve experimented with

  • Setting the participating fields’ type = ‘caculation’
  • Setting the participating fields’ type = ‘text’
  • Setting the participating fields’ type = ‘integer’
  • Casting the values as strings for the final comparison
  • Casting the values as integers for the final comparison
  • Setting the participating fields’ calculationMode=always
  • Setting the participating fields’ calculationMode=manual’
  • Probably other stuff that I’ve forgotten.  

Posts from 2021 and 2023 suggest this is a known issue and that the workaround I tried here is also known to be buggy. Is that correct? 

Are there any other ways to enforce required fields? Is this user error? Am I going crazy? 

0 Kudos
1 Solution

Accepted Solutions
Neal_t_k
Frequent Contributor

Attached is a simple example, that works in Connect, Field App (Desktop) and Web App.  It would help to see how you have yours xlsx setup, if you can provide a sample.

The main thing in this example is to use the repeat count column to initiate a repeat when additional selections are made, otherwise you are waiting for the user to initiate the repeat.

View solution in original post

0 Kudos
3 Replies
Neal_t_k
Frequent Contributor

Attached is a simple example, that works in Connect, Field App (Desktop) and Web App.  It would help to see how you have yours xlsx setup, if you can provide a sample.

The main thing in this example is to use the repeat count column to initiate a repeat when additional selections are made, otherwise you are waiting for the user to initiate the repeat.

0 Kudos
NickNuebel
Occasional Contributor

Neal, you're my hero. 

The only structural difference between my form and yours was that I used a relevant condition on my repeat. Removing that fixed the issue and now the form correctly enforces required fields from subsequent repeats! 

0 Kudos
Neal_t_k
Frequent Contributor

@NickNuebel Yep non relevant requirements aren't required,  Try using the "body::esri:visible"  column instead of "relevant" if you want to not show something until certain conditions are met but still enforce requirements.

https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-hidden-relevant-an...

0 Kudos