Add a password to a public form using pulldata()

Blog Post created by btkinal_SyrUniv on Mar 3, 2017

When Esri recently added the ability to share a form publicly it was a huge step towards giving us the ability to collect crowd sourced data without the need for data collectors to have their own organizational named user accounts. The one problem with a public form is anyone can collect and submit data to your feature layer. We had the need to collect crowd sourced citizen science data from a specific group of users but were not able to provide organizational named user accounts for a few hundred users, so the public form provide an avenue to do this. We also had the need to limit the people submitting data using our from to a group of known individuals, so a fully fully public form was not desirable. Below is an outline of a quick and simple solution to adding a password to a public form using the pulldata() function. This is by no means a perfect solution and is not totally secure, someone with knowledge of Survey123 form creation could figure out how to get into your form properties and find the usernames and passwords, but in our case we are not collecting sensitive data so the risk to someone hacking our form seemed minimal. 


The pulldata() function:

First for those unfamiliar with the pulldata() function pulldata  gives ability to look up and pull existing information into your form from an external csv file stored in your media folder. More information on pulldata can be found here in James Tedrick blog: Use existing data in your survey - the pulldata() function


Create your username and password list:

First step is to create a list of user names and password. A simple two column list saved as a CSV will work. This is stored in the media folder for your form.


Build your form:



What's going on here?

  • The first item (row 2) is just a note telling the user  to enter their username and password to continue.
  • Row 3 is a text question asking for the username and row 4 is a text field asking the password (set the bind::esri:fieldType to "Null' for the password field.
  • Row 5 is a hidden field using the pulldata() function to grab the predetermined password for the username from the stored CSV file.
  • Row 6 is a note field informing the user that the username/password combination incorrect. The relevant column set to ${passwordLU} != ${password} and ${password} != '' is saying display the note if the password value entered is not blank and not the same as the password associated with the username from 'user' table.

  • Row 7 begins a group which will contain all of your questions. The relevant column ${password} = ${passwordLU} and ${password} != '' will only open the group if the entered password is the same as the password looked up from the 'user' table.

  • Rows 9-12 are the form questions
  • Row 13 closes the group
  • Users will probably not want to have to enter their user name and password each time they fill in a form, so once those fields are filled in the user could set the answers to favorites and then save the form as a draft.


A couple considerations:

  • This is not meant to be a secure username/password protocol but more just to control who is using the form. It could also be simplified to just have the user enter a name then compare the entered name to one a name on a list.
  • The username and password are fields and will appear in your Survey123/AGOL feature class, you may want to take this into consideration when publishing your feature class and hide the password field.
    As of the release of Survey123 v.2.4 the bind::esri:fieldType can be set to "Null" for the password field eliminating the need have a password field in the feature layere See the blog The Power of Nothing 
  • For a more centralized data collection effort where you would know all of the devices you would want collecting data with your form, you could use the property() function to pull the device ID and compare to a list of "approved" device IDs using pulldata.

I am sure there will be several ideas that can improve on my procedure so please feel free to share.