Select to view content in your preferred language

How can I automate the update of a hosted feature class that has a related table without breaking the relationship?

124
1
Friday
Labels (2)
MDB_GIS
Occasional Contributor III

First some context on how I update all of our other AGOL data layers. I have built a model in ESRI's model builder that truncates the AGOL feature class and then appends the new data to the feature class. This works very well for updating most of our layers. 

The only layer we are having a problem with is our Zoning layer. It has a related table that contains variance information. Whenever I truncate and append the data to the zoning polygons and the variance table, it breaks the relationship class. Zoning polygons that previously had a related record now show "No records" in the map viewer. 

I can fix it by overwriting the zoning layer in AGOL, but this can't be automated because there is no geoprocessing tool available for using in model builder to automate the overwrite. I have tried using python as well but I am no programmer and thus far I have not been able to get it to work. Does anyone have any ideas on how I can automate this update of our AGOL data? It is crucial that our data online stay up to date so I have to figure out something. 

0 Kudos
1 Reply
MobiusSnake
MVP Regular Contributor

I'm guessing what's happening here is this:

  • Your relationship class uses a Global ID primary key and a GUID foreign key
  • When you append to the feature class, the Global IDs are being automatically assigned instead of using your source's Global IDs
  • When you append to the related variance table, the GUIDs are using the source values.
  • Since the keys no longer match, there are no relationships.

There's a geoprocessing setting that allows you to preserve Global IDs when you append, but I don't believe this is supported on hosted feature layers.  I might be wrong though, that could be worth a try.

If my assumptions above are correct, and that setting isn't supported, I think you'll need a way to map your source's Global IDs with the reassigned values, creating kind of a lookup table.  With that in hand, you could modify the GUIDs in your related table, replacing the source values with the new values.  Do you have any unique identifiers on your features besides the Global ID and Object ID?  If you do, you might be able to make this work with a series of joins and calculations, if not the only reliable approach I can think of would be to use Python in some way (either an ArcPy insert cursor or one of the editing calls from the ArcGIS API for Python).

0 Kudos