Select to view content in your preferred language

Edit the Creator or the Editor of a feature

694
1
Jump to solution
09-06-2022 01:15 AM
AngelRomoSandoval
Regular Contributor

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:

  1. The field Editor is always written protected, is that the problem? ( Screenshot: AngelRomoSandoval_0-1662451654918.png)
  2. Should I modify the attribute in the Feature-Class instead of in the Layer?

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")

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

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

- Josh Carlson
Kendall County GIS

View solution in original post

1 Reply
jcarlson
MVP Esteemed Contributor

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

- Josh Carlson
Kendall County GIS