Hi All,
I used this script to delete all the features from a hosted feature layer where it had relationships and had sync capability enabled on it.
https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html?highlight=query#arcgis...
import arcgis
from arcgis.gis import GIS
gis = GIS("https://site.maps.arcgis.com", "username", "password")
feature_layer_item = gis.content.search("<item-id>")[0]
flayers = feature_layer_item.layers
flayer = flayers[0]
max_objid = flayer.query(out_statistics=[{"statisticType":"MAX","onStatisticField":"OBJECTID","outStatisticFieldName":"MAX_OBJ"}], return_geometry=False)
maxoid = max_objid.features[0].attributes['MAX_OBJ']
i = 0
step = 20000
while i <= maxoid:
i += step
flayer.delete_features(where=f"OBJECTID <= {i}")
print(i)
print("Feature Layer was truncated")
Thanks,
Imtiaz