How do I edit a feature layer's data when it has replicas

09-11-2019 10:08 AM
New Contributor II


We are currently hosting features in ArcGIS Online to be used with the Collector App. We plan to update these features nightly from an SDE environment with Python. Due to some of the network security implementations, we are restricted from using the REST endpoints from an ArcServer instance to create these feature layers. I have written a script to do this, but the issue I am running into is when a user downloads an area for offline use a replica is created. This replica stops the feature's underlying data source (Service Definition File) from updating the feature. A work around I have found is to unregister the replicas then update the feature, but this causes sync errors on the user's collector area when they attempt to re-sync their downloaded area. Does anyone know of a cleaner solution to updating features with outstanding replicas?

 # checks if feature exists:
    # Gets access to the existing service definition object
    sdItems ="{0} AND owner:{1}".format(, self.user), item_type="Service Definition")
    sdItem = sdItems[0]

    # Updates feature data

 # if feature does not exits...
 except IndexError:
    # the service definition file is uploaded to ArcGIS Online
    sdItem = self.gis.content.add(feature.getProperties(), data=sd)

 # Gets access the the feature collection object
 featureCollect ="{0} AND owner:{1}".format(, self.user), item_type="Feature Layer       Collection")

     # Attempts too publish the service definition to the feature layer
     featureService = sdItem.publish(overwrite=True)

 # if the feature cannot be updated...
 except Exception as ex:

    # Accesses Feature Collection object
    featureService = self.gis.content.get(feature.service_id)
    FeatureCollection = FeatureLayerCollection.fromitem(featureService)

    # Unregisters outstanding replicas
    for replica in FeatureCollection.replicas.get_list():

    # Disables Syncing
    FeatureCollection.manager.update_definition({"syncEnabled": False})

    # Publishes Service Definition to Feature Layer
    featureService = sdItem.publish(overwrite=True)

 # Updates feature tags
 featureItem = self.gis.content.get(
 featureItem.update(item_properties={'tags': feature.tags})

 # Enables Offline Syncing
 FeatureCollection = FeatureLayerCollection.fromitem(featureItem)
 FeatureCollection.manager.update_definition({"syncEnabled": True,

 # Updates editing capabilities

Thanks for your help!


4 Replies
Occasional Contributor

Chris, did you ever find a solution to this?

0 Kudos
by Anonymous User
Not applicable

I'm hitting the same issue with our Open Data layers which are scripted to be updated (via an overwrite) weekly. Sync was enabled on them to allow for use in Collector/Explorer. When users take a map offline this then creates the replicas.

Aside from having two feature layers, one solely for Open Data and another for mobile users I can't see many other options. Even then the feature layers for mobile users would have to be managed via comms with users to try and get as many as possible to remove their offline maps before doing an update. The update would have to remove any outstanding replicas. I've contacted Esri support but thus far they've got no solution.

At minimum I've suggested they at least catch it as an error rather than throwing “Job failed” when carrying out a publish with the ArcGIS API for Python and an even less useful "ERROR 999999: Something unexpected caused the tool to fail…" message when using ArcPy.

0 Kudos
Occasional Contributor III

Also coming here to see if there was ever a solution? I heard in a webinar that you could create views for sharing/offline use, and then update the root layer that the view(s) stem from, but I've been trying that today and I can't overwrite the layer if there are maps downloaded in Field Maps. Frustrating, I would love to be able to keep our reference data more up to date without having to disrupt folks' field workflows. Is there an easier way? I've tried editing the layers directly but there are too many features for me to do this efficiently. 

0 Kudos
New Contributor II

The work around I went with isn't great, but works for us. If there are replicas, I loop through and unregister them. This means the user will get errors when they sync, so they have to delete their offline copy and download a new one. The edits seem to come over though. Using the predefined areas helps to alleviate some of the issues. 

0 Kudos