Notify users a Survey123 form need to be updated, comparing version using connection with a table hosted in AGOL

3213
2
11-01-2019 10:54 AM
FlorenceRaimbault
New Contributor III
7 2 3,213

This is my contribution to notify to an user (if not using survey123 in disconnected mode) than the form needs to be reload.

How it‘s working:

 You publish a table in AGOL with a field contained the version info (VAL_VERSION), each time you open the form in the field survey123 a function *js send and ID, retrieve the version and the calculation perform the comparison

This example uses a javasript function to send and ID and retrieve the version

  

What you need:

  1.  The javascript code in the zip (contain, the *.xls and the *.js function)
  2. Create a reference table or a feature service hosted  in AGOL( don't forget to share the table to the same group using yours Survey123)
  3. The url of the reference table to retrieve the official value. The table is publish in AGOL. I provide a example of the table, see the cvs to create the table on AGOL.
  4. Add an  folder named "extensions" in the survey123 project  containing the *.js.

Note :To make the JS functioning, each time you modify this the *.js file you need to close and reopen the survey123 connect app

Detail:

All the configuration are done from the xls

 This is the detail of the values in the XLS ant in the JS function :

 Javascript  function:

 function QueryFeatureLayerByField(featureLayer,Queryfield,Value,outFields,token,debugmode)

 Pulldata *.xls:

 pulldata("@javascript","myFunctionsFR_Demo.js","QueryFeatureLayerByField",${myURLversion},"ID",string(${ID_version}),"*",pulldata("@property","token"),true)

  

variable in the function *.js values pulldata correspondance details
featureLayer "https..../0" ${myURLversion} table's URL
Queryfield ID "ID" the ID field for the query
Value 1 string(${ID_version}) the value to retrieve in the query , ID = 1
outFields * "*" fied retrieve from the  query. ou can choose all the field * or a specific field “VAL_VERSION”

 

Survey123 connect:

 Result:

Exemple of the table:

 

This method could be also use to retrieve other info (from the survey himself, past summit ) to populate default value info.

thanks for the *.js code and the idea  to @Chelsea Rozek  for the post  Force update to new survey

and the post https://community.esri.com/message/823053-pulldata-json-to-query-feature-service-with-token

2 Comments