Limit für Einträge in einem Survey123

602
1
10-02-2024 02:26 AM
Status: Open
Labels (2)
MatthiasG
Emerging Contributor

Survey123: Gibt es eine Möglichkeit, eine Umfrage zu beenden, sobald eine bestimmte Anzahl z.B. 100 öffentlicher Einträge vorgenommen wurde? I Sobald der Schwellenwert von 100 erreicht ist, möchte ich die Umfrage automatisch ausschalten lassen.

1 Comment
AlfredBaldenweck

You can do it, but it's a little hacky and only works for Online Surveys; offline will not work. Also, it's kind of awkward in that it requires you to close and reopen Survey123 for it to actually work. 😕

  1. Create your survey. 
  2. Add the following questions to the top of it:
    1. recordcount
      1. Type: integer
      2. Appearance: hidden
      3. Calculation: pulldata("@layer", "getValue", "attributes. TotalCount", concat("https://services5.arcgis.com/jMCHJcLe13FaKCFB/arcgis/rest/services/US_Counties/FeatureServer/1", '?outStatistics=[{"statisticType": "count","onStatisticField": "objectid","outStatisticFieldName": "TotalCount"}]'), concat("objectid >0"))
        1. Make sure that objectid is lowercase.
      4. bind::esri:FieldType: null
    2. warning
      1. Type: Note
      2. required: yes
      3. label: <font color = "red">You are unable to submit because the survey has reached its limit of responses.</font>
      4. relevant: ${recordcount}>=ANY NUMBER YOU WANT TO LIMIT IT TO. I chose 20
      5. bind::esri:FieldType: null
  3. Publish the survey.
  4. Open the survey item in your portal
    AlfredBaldenweck_0-1729014519685.png
  5. Under Layers, go to the feature service created by the surveyAlfredBaldenweck_1-1729014567107.png
  6. Scroll down to "URL", copy it, and add "/0" to it.
    AlfredBaldenweck_2-1729014633239.png
    https://yourURLhere/hosted/rest/services/Hosted/serviceIDhere/FeatureServer/0
  7. Back in Survey123 Connect, copy that URL into the calculation for the recordcount question, replacing the dummy one I put up there.
    1. pulldata("@layer", "getValue", "attributes. TotalCount", concat("https://yourURLhere/hosted/rest/services/Hosted/serviceIDhere/FeatureServer/0", '?outStatistics=[{"statisticType": "count","onStatisticField": "objectid","outStatisticFieldName": "TotalCount"}]'), concat("objectid >0"))
  8. Republish the survey.
  9. Download the survey in the field app.
  10. Start collecting. After the number of records has been surpassed, that note will pop up with the warning and the required message, not letting you submit any more records.*
    1. I could only get this to work after reopening the app, unfortunately.

Tried to video it but ran into trouble editing it. This is how it should look

AlfredBaldenweck_3-1729020196409.png

Edit 10/30/2024: It appears that this might be made easier in the November release? Will update again when it comes out.