Count specific responses and restrict survey submission?

246
5
3 weeks ago
RHammers
New Contributor III

Hello!

I have a single survey that will be used to manage registration for multiple upcoming events that each have at maximum 25 seats. I would like to limit how many people can register for each event to 25, so that if someone attempts to register for a full event, they cannot.

Example:

Which event would you like to attend? (select_one)

1. Event A

2. Event B

3. Event C

As long as there are less than 25 registrants for whichever event they have selected, they can register. But when the event is full (25 registrants), a note appears that let's the registrant know there is no room, and the survey cannot be submitted until a different selection is made.

Thanks in advance!

0 Kudos
5 Replies
ZacharySutherby
Esri Regular Contributor

Hello @RHammers

You can use pulldata("@layer") to query the feature service your survey points to and return the count of the number of records that match the specific event. For example, if someone selects Event C the pulldata("@layer") function would query the data and return the number of records that have the value Event C. You can then configure logic in your survey so that if that number is 25 or more then there's a constraint on the event select_one question preventing the user from submitting. 

Please see the Request parameters section of the Query a feature layer documentation for more information on how to return the count. 

Thank you,
Zach
RHammers
New Contributor III

Thank you @ZacharySutherby for the reference. Do you know if this is something that can be achieved on a single line in my xls?

I'm struggling with how to implement this, do you happen to have any examples in xls format that you can share?

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello @RHammers

It wouldn't be in a single line the calculation would need to go in it's own question so that value can be referenced in the event select_one question. The separate question can be a calculate question type that is not visible on the form and is only used to store calculations on the back end. 

Another good resource to see how to summarize data using pulldata("@layer") in XLSForm is the Query a feature layer sample available in Survey123 Connect. 

ZacharySutherby_0-1712789353255.png

 

Thank you,
Zach
0 Kudos
RHammers
New Contributor III

@ZacharySutherby Got it working, thanks! Is it possible to use this technique to check whether a file has been uploaded for a 'file' question?

0 Kudos
DianaKalil
Esri Contributor

@ZacharySutherby  Hello, what if there are no events but dates? would the same logic apply?  Thanks

 

0 Kudos