Survey123 Connect using SDE layers

In this post:

This post goes over creating Survey123 forms using Survey123 Connect, and Feature Layers registered to an SDE. It is important to prepare SDE data properly in order for the XLS form to work with the database schema. Additional information could be found here – Use Survey123 with existing feature layers—ArcGIS Survey123 | Documentation.

  • Important but obscure property of a feature layer – ‘supportSpplyEditsWithGlobalIDs’ – must be set to ‘true’ if looking at a JSON of a layer that would be used to collect the data. This article covers some important details – How to enable supportsApplyEditsWithGlobalIDs on y… – Esri Community
  • Make sure to assign GlobalIDs to the layer all participating relations;
  • Attribute table fields that will be tracking creators/editors should be set to read only;
  • Publish feature layer as registered to SDE with enabled editing;
  • Versioning is not recommended;
  • Survey123 fields that would contain multiple choices, in the SDE are supposed to be assigned domains. Survey123 could take care of that.

Creating feature layer (with related table(s))

  1. Create primary feature layer in your SDE as a point, line or a polygon. Make sure it has a unique field that would be used as a primary key. 
  2. Enable GlobalIDs
  3. Enable GUIDs for the parent layer (as per Survey123) – Calculate GUIDs.
  4. Create a second layer(s) that would be related to the first one. Enable GlobalIDs and Attachments for this layer. The second layer could be just a table without any geometry. Make sure one of the fields is set to be a foreign key. 
  5. IMPORTANT: in the related attribute table, create a GUID type field called “parentglobalid”.
    1. It can stay empty, but it has to be GUID type and it has to be in the attribute table of any related feature. Otherwise, when trying to publish a survey from Survey123 Connect, you will receive a message “Unsupported relationship type esriFieldTypeString …”. Here is a post that actually was helpful for me – Solved: Unsupported relationship type when publishing – Esri Community
  6. Create relationship class using geoprocessing tool. Primary keys could be any data type.
  7. Load both the parent layer and the related layer, or table(s) into a map in ArcPro. Share from the Ribbon as a Web Layer. Published data should be registered to SDE, with feature layer enabled. 

Once published, the parent layer and all related tables will be showing together when opened in the Portal.

Note: if working in ArcGIS Online, there is a limit on how many tables could be related.

Creating Survey123 form using published feature layers

Once a blank feature layer is created, open Survey123 Connect. This desktop application could be downloaded here – Get ArcGIS Survey123 Connect – Microsoft Store.

Make sure to connect to your Portal or ArcGIS Online account where feature layer that would be used is stored.

Click “+New survey” to start a new survey. Select “Feature service” in the provided list, navigate to the feature layer. If the data was created and published correctly, Survey123 will import the schema as is. Further manipulations will be done in the XLS Form.

Customizing XLS forms

  • Detailed information about XLS forms could be found here – XLSForm Docs

XLS forms will be opened in Excel. Several tabs will be created – first three (survey, choices, settings) are the ones that allow to manipulate forms behavior. Remaining tabs are for references.

Navigate to ‘settings’ tab, and take a look at the first four columns:

  • form_title – Custom name of your form
  • form_id – points to the feature layer that would be subjected to data collection
    • if you need to perform survey on the related table only, change the name to the name of the table is it is seen in the Portal;
  • submission_url – the format is important as it indicates which online feature layer is the subject of the survey.  The format should be as follows: https://domainName.com/portal/sharing/rest/content/items/<feature layer Portal ID here>
  • instance_name – this field is used to customize how results will appear listed in the Sent folder of the Survey;

Customizing survey fields

This is a rather broad subject, so I will refer to online sources provided below. I am only highlighting some aspects that have been used while writing this post.

  • Automatically calculating a field with only a month based on another field in the dateTime format. This field should be set as a string if entering as a text (January, February, March etc…). Use ‘calculation’ column in the “survey” tab:

format-date(${original field name in dateTime format}, ‘%b’)

Additional information about date formats in Survey123 could be found here – Dates and Time in Survey123 – Esri Community.

  • Display fields based on the selection in the previous field. Fields will be hidden in the form until a specific selection is made in the previous field. Here we will use a “yes” / “no” answers. If “yes” is selected, than new fields will be shown. Use ‘relevant’ column to control this functionality:

${name of the original field}=’Yes’

  • Automatically populated date and time field(s)  with current date and time using ‘default’ column:

now()

Publishing survey

Once form is configured, click “Publish” button on the left-hand side. Few things I learned the hard way:

  • If you would like to have a custom picture used as a thumbnail for your survey, place it in the survey folder and point to that location from the “Details” found at the bottom of the Survey123 Connect.
    • On the C:Drive surveys’ folders could be found here – C:\Users\username\ArcGIS\My Survey Designs

Even if a survey was published with no errors in Survey123 Connect, sometimes it might not be accessible from the web interface. In this case, I had to repeat the process several times, checking all my relations, GlobalIDs and GUIDs. I am yet to determine the root cause.

Connecting Survey123 with other Apps

These are brief notes to capture my overall experience. 

  • This is a very good article that covers the process in detail – Understanding Survey123’s custom URL Scheme – Esri Community
  • a very usefull tool to generate custom urls – Announcing a handy tool to generate Survey123 URLs – Esri Community. Make sure you have exact parent table primaryID field and child table foreign key field names before using this field.
  • To open Survey123 with the specific parent primaryID pre-filled based on a feature that you select in another app (Field Maps, Collector, Explorer), use “Custom attribute display” to configure pop-ups.
    • To display attributes from the parent table, you will have to manually enter them in this format:

Station Number: {station_no}

Curly brackets include actual column names

    • To add a link that would open Survey123 app (in this case we are dealing with mobile devices), use custom url in this format:

arcgis-survey123://?itemID=d327b411831c42df9cd7e17a30fc48bd&field:station_no_insp={station_no}

Note that this format might not work on the computer if testing thru the web browser, as it is pointing to the application that has to be installed on the same device. Try testing it on a mobile device.

Portion insp={station_no} represents foreign key from the child table – primary key in the parent table.

Additional Resources: