Hello,
Having the existing ability to turn a survey off based on a date setting/range is incredibly helpful within Survey123. However, if I wanted to turn the survey off based on a MAX count of something for example, I'm a bit stumped. Is there a way in Survey123 to do this programmatically via Arcade or a script OR if for example the survey was being deployed through a widget in Experience Builder would it make more sense to deal with it there?
Best
GR
Hi. Using the new pulldata("@layer") function you can count the number of records submitted to a survey (granted that your survey layer has query capabilities enabled). With that, you can build a constraint to prevent further submits, and show a message indicating that the survey is closed.
Check out this video on minute 22:10, as it describes how to do it. Also some additional help in this blog, and this help topic.
The above is not quite the same as 'closing the survey', but it may do it for you.
Ismael,
The video and links have been very helpful. I feel like I am almost there. Below
type name label hint
date | creation_date | Creation Date: | |
select_one list_name | event_date | Choose Your Event Date | <i>Choose a date.</i> |
text | last_name | Last Name | <i>Type last name here.</i> |
text | first_name | First Name(s) | <i>Type first name(s) here.</i> |
integer | fridayAdult | Adult(s) Attending Friday | <i>Enter # of adults.</i> |
calculate | my_layer_url | ||
calculate | my_query_url | URL | |
integer | record_count | Record Count |
calculation constraint constraint_message relevant choice_filter repeat_count
int(${fridayAdult})>0 and int(${fridayAdult})<=10 | Value must be between 1 and 10 | ${event_date}='date_1' | |||
string("https://services8.arcgis.com/m2qDIZgo1Sbgu0rc/arcgis/rest/services/service_f753da0c124141f0872780070...") | |||||
concat(${my_layer_url},"?outStatistics=[{'statisticType': 'count','onStatisticField': 'objectid','outStatisticFieldName': 'fridayAdult'}]") | |||||
pulldata("@layer","getValue","attributes.fridayAdult",${my_query_url},"1=1") |
Sorry for the messy table but for the most part the entries are as you have them in your demo.
My thought/hope would be that the concat calculation would act as a running sum "fridayAdult" (ie total count of all the record entry values added together) which I could then use with constraints to alert the user the max fridayAdult count had been reached say at 10.
Am I misinterpreting all this? Thanks again for the help. I'm learning alot.
GR