adding a repeatable table to existing feature

353
1
Jump to solution
05-20-2023 04:05 AM
tendtreesTC
New Contributor III

I have a scenario where I have an existing feature with basic data and polygons for 500+ sites.

I now need to carry out an audit on each of these sites so I would like to set up a repeatable field using survey123 connect.  
I am able to generate a survey in 123connect based on the existing feature service however I am not able to add a repeat field and then publish the survey.

Is there a way for me to do this?

Alternatively is there a way for me to create a completely new layer in survey 123 and then copy all of the features from the existing layer which I can then edit using the overview feature in Survey123?

Any assistance would be most appreciated thank you.

 

0 Kudos
1 Solution

Accepted Solutions
MobiusSnake
MVP

While it's possible to add a new related table to a layer in an existing service, it's not easy, you need to use the REST API or the Python API, and it's not a simple call in either.  Additionally, if you make a mistake, it can be very difficult to fix it.

I would create a new service with the related table.  Note that this will require ArcGIS Pro and an Editor license:

  • From the item page of your existing service, export your data to a File GDB, then download and unzip the File GDB.
  • In ArcGIS Pro, open the File GDB and create a new table with the fields you'll need in Survey123.  Additionally, add a GUID field named "parent_id" or something like that.
  • Make sure your original layer has a Global ID field; if it doesn't, add one now.
  • Create a relationship class from your original layer to the new table, using the Global ID and GUID fields as keys.  You'll want it to have one-to-many cardinality, composite relationships, and forward messaging.
  • Close ArcGIS Pro, then navigate to the FGDB's folder in your file system and zip the FGDB up.
  • In ArcGIS Online, add the FGDB as a new item and publish to create a new hosted feature layer.
  • Create a new survey from this new layer.

One caveat - if you rely on editor tracking, this could cause problems.  All of your old records that are migrated to the new service this way will have their creator and editor set to the user performing the service creation, and created-at/edited-at timestamps will be lost as well.

If you don't have Pro and an Editor license, publishing your form with the repeat as a new service then copying the records across is likely what you'll need to do.  There are several ways you could do this, I think the Python API would be the best, but this isn't trivial, particularly if you have attachments.

View solution in original post

0 Kudos
1 Reply
MobiusSnake
MVP

While it's possible to add a new related table to a layer in an existing service, it's not easy, you need to use the REST API or the Python API, and it's not a simple call in either.  Additionally, if you make a mistake, it can be very difficult to fix it.

I would create a new service with the related table.  Note that this will require ArcGIS Pro and an Editor license:

  • From the item page of your existing service, export your data to a File GDB, then download and unzip the File GDB.
  • In ArcGIS Pro, open the File GDB and create a new table with the fields you'll need in Survey123.  Additionally, add a GUID field named "parent_id" or something like that.
  • Make sure your original layer has a Global ID field; if it doesn't, add one now.
  • Create a relationship class from your original layer to the new table, using the Global ID and GUID fields as keys.  You'll want it to have one-to-many cardinality, composite relationships, and forward messaging.
  • Close ArcGIS Pro, then navigate to the FGDB's folder in your file system and zip the FGDB up.
  • In ArcGIS Online, add the FGDB as a new item and publish to create a new hosted feature layer.
  • Create a new survey from this new layer.

One caveat - if you rely on editor tracking, this could cause problems.  All of your old records that are migrated to the new service this way will have their creator and editor set to the user performing the service creation, and created-at/edited-at timestamps will be lost as well.

If you don't have Pro and an Editor license, publishing your form with the repeat as a new service then copying the records across is likely what you'll need to do.  There are several ways you could do this, I think the Python API would be the best, but this isn't trivial, particularly if you have attachments.

0 Kudos