Have a question regarding automatically updating an existing Feature Layer in AGOL. I’ve looked through all the little help screens I can find, but can still find no answer. This is the last section of a bit of code I’ve written to update a Feature Layer. Program pulls FE_Insp from the AGOL account just fine, makes a copy of the file as a csv. It then runs a couple of reports, and then does an overwrite of one field within the CSV (from “Yes” to “No”) … done to reset an inspection form to be used in Collector every month.
It will not allow me to re-upload and re-publish the new file. I can go to the site and manually walk through the update portion. It has changed to Append, and now wants a Unique Identifier set (GlobalID or ObjectID) … not a big deal to do manually, but how do I pass that identifier in just this little bit of code? Leaning towards the GlobalID if that would help.
# In[1.1] - FE_Insp ... Access the AGOL Account.
gis = GIS("https://www.arcgis.com", "user", "password")
# In[1.2] ... Search for 'FE_Insp' feature layer collection
search_results = gis.content.search('title: FE_Insp', 'Feature Layer')
# In[1.3] ... Access the first Item that's returned
fh_item = search_results
# In[1.4] ... from arcgis.features import FeatureLayerCollection
fh_flayer_collection = FeatureLayerCollection.fromitem(fh_item)
# In[1.5] ... call the overwrite() method which can be accessed using the manager property
print("1.5 - Feature Layer FE_Insp has been updated")