Repeats - form is valid when required repeats are completed

344
5
05-28-2023 03:03 PM
FrankHerbert
New Contributor III

I have a survey containing a repeat. The repeat count is set to 20, because for every survey there must be 20 responses.

Currently the user could potentially submit the survey when less than 20 responses have been completed. This will cause problems further down the line so I would like the survey to only be valid when the repeat count is 20 - is this possible? In other words, repeat count is 20 meaning the user can submit or; repeat count is 17 meaning the user can't submit until all 20 repeats have been completed.

Please can someone offer advice?

0 Kudos
5 Replies
JoshuaSharp-Heward
Occasional Contributor III

Hi Frank,

If you set the repeat_count column for the begin repeat row to 20 that will make it so that the repeat block is forced to repeat 20 times.

This doesn't automatically mean that the user has to fill in the form 20 times (as currently it can create 20 repeats with null values) - however if any of the questions within the repeat have the required column set to "yes" then that will mean that the user does have to complete all 20 records before they can submit. Hope that helps!

Kind regards,

Josh

0 Kudos
FrankHerbert
New Contributor III

Hi Joshua, thanks for the reply but unfortunately this doesn't seem to work in the desktop publishing space. When I validate the form there are no error messages, suggesting the form could be submitted. Perhaps this is different once the form has been published and downloaded. I'm still trialling mandatory question types to ensure responses are registered to each of the repeats to avoid user error. Will keep trying!

0 Kudos
JoshuaSharp-Heward
Occasional Contributor III

Hi Frank,

It worked for me in the desktop publishing space! Would you be able to post the survey123 form or at least the relevant part from the repeat so I can take a look? Here's how mine looked:

JoshuaSharpHeward_0-1685426106784.png

 

JoshuaSharpHeward_1-1685426132880.png

 

0 Kudos
DougBrowning
MVP Esteemed Contributor

I kept having lots if issues with repeat count similar to this and more.

In the end I created a counter using count() then set a constraint on that.  That way the repeat grows as they add then gives an error if more or less than 20.  Works much better with complicated forms.

0 Kudos
FrankHerbert
New Contributor III

Thanks Joshua and Doug. I'm offline this morning but will try to get on later today and see if I can get the repeat to work as intended. If I'm still struggling then I'll upload the survey for you to look at. Thanks again guys, appreciate the help.