Survey123 feature class as a related table

36564
87
Jump to solution
08-22-2016 09:43 PM
GordonSumerling
Esri Contributor

Hello All,

I need to understand how it might be possible for my Survey123 feature class to be a related table to a polygon feature in the map.

In essence I have a farm field feature class and I want to perform an inspection against this. Conventionally, I would create a feature class to represent the farm in ArcMap and then create a related feature class in ArcGIS that is the inspection feature class. Now I could use this in collector. However, I want to take advantage of the field manipulation capability of Survey123. 

The inspector already knows the farm ID so he just needs to perform the inspection with survey123. So the question is how do I publish the survey123 feature class and then relate it to the farm polygon feature class in ArcGIS Online?

Cheers

Gordon

1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

You are a brave man!

You are correct: you must make the inspection table a layer (must include a shape field with  points) and it must be listed first in the feature service. Survey123 will look for the layer with index 0.

Updated response June 15: In 2.0 and newer versions, you can create a survey that works against an existing related table. In Connect, go to New Survey, then select Feature Service and pick your feature service from the gallery. Once the XLSForm is loaded, eliminate the questions relative to the parent layer. Eliminate the rows with the  begin and end repeat statemnts. Then change the FormID value in the Settings tab so it references the name of the related table you want to edit.

View solution in original post

87 Replies
IsmaelChivite
Esri Notable Contributor

Hi!  You can take a couple of approaches here. The simplest  one is to use relates in ArcMap or ArcGIS Pro map documents. Through a relate you will be able to say click on a Farm polygon and navigate to all its related inspections over time. Here how you do it:

  • First add your Farms polygon layer (from a shapefile, file geodatabase or other source) into your map. Then add your Survey123 feature layer.
  • Once you have both layers in the map, you can create a relate between both layers by right-clicking on the Farms feature layer and selecting the Join and Relates option in the context menu.

I like relates because you can create them across layers coming from very different sources:  a database, a file, a feature service.  The not so good aspect of relates is that they are useful in ArcMap and ArcGIS Pro, but not in web maps or web applications.

The other approach is to use geodatabase relationships. The beauty of them is that these relationships can be discovered by many different apps including Desktop and Web apps.  The issue with geodatabase relationships is that their creation is much more involved, forcing you to bring your Farms and Inspections into the same enterprise geodatabase or hosted feature service, and also make sure Survey123 can work against your inspections table using the submission URL setting.  If using the submission URL, ensure that you inspections table is actually a layer and the first in your feature service.

This blog post is a bit obsolete but still describes very well what the differences are  between relates and relationships. This help topic is a good reference too.

GordonSumerling
Esri Contributor

Hello Ismael,

i am am going to use the second option here. Just to verify the submission URL, I can have many feature layers in this as long as the inspection feature is first in the layer list as I cannot specify the position in the feature service when using the submission URL. For example "feature service/0" 

cheers

Gordon

0 Kudos
IsmaelChivite
Esri Notable Contributor

You are a brave man!

You are correct: you must make the inspection table a layer (must include a shape field with  points) and it must be listed first in the feature service. Survey123 will look for the layer with index 0.

Updated response June 15: In 2.0 and newer versions, you can create a survey that works against an existing related table. In Connect, go to New Survey, then select Feature Service and pick your feature service from the gallery. Once the XLSForm is loaded, eliminate the questions relative to the parent layer. Eliminate the rows with the  begin and end repeat statemnts. Then change the FormID value in the Settings tab so it references the name of the related table you want to edit.

GordonSumerling
Esri Contributor

Hello Ismael,

This worked!! Excellent. I now have Survey123 writing to a related feature table in ArcGIS Online. 

Thank you for your assistance.

Gordon

GeomatiqueTI
New Contributor II

Hello M Summerling,
For everything to work, Did you create your survey with the rowid, parentrowid fields and the esrifieldtype ?? Is your table must contain a shape fields?
I ask because I find it extremely interesting, but I already have my relationshipClass table inspection and I wonder if I have to redo the structure of my inspection table by turning it to point layer with the new fields.

Thanks

0 Kudos
GordonSumerling
Esri Contributor

Hello Patrice,

In order to make this work.

First of all I created the Survey table, with all the attributes I was looking for.

I then downloaded the Survey table in a File Geodatabase. This creates the structure I needed.

I then related the Survey table to the feature class I wanted it to work with.

Then in ArcMap I added both the feature class and survey table. With the survey table the first item in the table of contents.

I then published this to ArcGIS Online.

Finally I updated the Survey123 project in access to point to the URL of the published feature service.

The key here is I did not try and replicate the Survey123 feature class in ArcMap. I let Survey123 generate the feature service for me then I copied it back to ArcMap and finally republished it. That way everything is as it was designed in Survey123.

Cheers

Gordon

BrandonKeinath1
Occasional Contributor III

Hi Gordon,

Can you be more specific about how you were able to make the table the first layer in ArcMap?  I'd also like to use survey123 to edit related tables but I'm struggling to make it the first layer.

Thanks,


Brandon

0 Kudos
GordonSumerling
Esri Contributor

Brandon,

The workflow I used is as follows:

  1. Create a new Survey123 project in Survey123connect and load to ArcGIS Online
  2. Download the feature service to a file geodatabase
  3. In the file geodatabase create your primary feature. Ensure it has a common ID with the survey123 feature class.
  4. Create a geodatabase relationship between the primary feature class and the survey123 feature class using the common ID
  5. In a Map document add both layers with the Survey123 feature as the first item in the table of contents
  6. Publish as a new feature service in ArcGIS Online (The survery123 feature class should be ~/FeatureServer/0)
  7. In the Survey123connect app, open the spreadsheet and switch to the settings tab
  8. Update the submission_url parameter to match the feature service for the ArcGIS Online Feature Service
  9. In the Survey123 project folder delete the .iteminfo file
  10. In ArcGIS Online delete the original associated survey123 folder
  11. Republish the Survey123 project and it should associate with the specified feature service.

Hope this helps

Gordon

BrandonKeinath1
Occasional Contributor III

Thanks for the quick reply Gordon.  I'm still a little confused so let me try and clarify my question.  I'm looking to have a feature class to table relationship and use Survey123 to add rows to the table.  When I read your step 4 it sounds like you are still using two feature classes (primary feature class and survey123 feature class).  Is that right?

Thanks for your help

Brandon

0 Kudos