Select to view content in your preferred language

Can I Turn Off Survey Programmatically?

831
2
11-21-2022 04:48 AM
GregReinecke
Frequent Contributor

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

0 Kudos
2 Replies
IsmaelChivite
Esri Notable Contributor

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.

GregReinecke
Frequent Contributor

Ismael,

The video and links have been very helpful. I feel like I am almost there. Below 

type      name      label      hint

datecreation_dateCreation Date: 
    
select_one list_nameevent_dateChoose Your Event Date<i>Choose a date.</i>
    
textlast_nameLast Name<i>Type last name here.</i>
textfirst_nameFirst Name(s)<i>Type first name(s) here.</i>
    
integerfridayAdultAdult(s) Attending Friday<i>Enter # of adults.</i>
    
calculatemy_layer_url  
calculatemy_query_urlURL 
integerrecord_countRecord Count 

 

calculation        constraint         constraint_message        relevant         choice_filter          repeat_count

      
      
      
      
      
      
      
 int(${fridayAdult})>0 and int(${fridayAdult})<=10Value 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

0 Kudos