Hello,
I would like to edit the Editor of a Feature in a Layer in a published Feature Class. I run the script but AGOL does nothing, also, I get no errors.
I am asking myself possible problems:
My code:
PolygonOnlineId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
PolygonOnline = gis.content.get(PolygonOnlineId)
PolygonOnlineLayer = PolygonOnline.layers[0]
PolygonOnlineLayerFSet = PolygonOnlineLayer.query()
PolygonOnlineLayerFSetFeatures = PolygonOnlineLayerFSet.features
for f in PolygonOnlineLayerFSetFeatures:
if f.attributes['Editor']=='xxxx': #the script finds the features with editor == xxxx
fEdit = f
fEdit.attributes['Editor'] = 'yyyy' #the scripts changes nothing!
update_result = PolygonOnlineLayer.edit_features(updates=[fEdit])
print("Editor changed!")
else:
print("editor not changed")
Print("Done")
Solved! Go to Solution.
The editor field is meant to be "untouchable" because it is part of editor tracking. Being able to change the purported creator / editor of a feature can lead to situations in which a user appears to be responsible for edits they did not make.
Why, exactly, would you need this field edited?
If you were publishing an offline layer to AGOL, you should get the option to "preserve editor tracking". Theoretically, you could download the layer, disable editor tracking, update the field in question, re-enable editor tracking, then publish with the option to preserve those fields. I can envision some situations in which the editor fields might be wrong (I've got a few of them myself, actually!), so I can understand needing to do this, but I also think that the process should not be easy, for the sake of data integrity.
https://support.esri.com/en/technical-article/000021839
The editor field is meant to be "untouchable" because it is part of editor tracking. Being able to change the purported creator / editor of a feature can lead to situations in which a user appears to be responsible for edits they did not make.
Why, exactly, would you need this field edited?
If you were publishing an offline layer to AGOL, you should get the option to "preserve editor tracking". Theoretically, you could download the layer, disable editor tracking, update the field in question, re-enable editor tracking, then publish with the option to preserve those fields. I can envision some situations in which the editor fields might be wrong (I've got a few of them myself, actually!), so I can understand needing to do this, but I also think that the process should not be easy, for the sake of data integrity.
https://support.esri.com/en/technical-article/000021839