AnsweredAssumed Answered

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

Question asked by camowry on Sep 11, 2019
Latest reply on Jul 14, 2020 by



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!