Select to view content in your preferred language

Re-enable editor tracking and use existing fields?

1156
7
05-04-2023 03:00 PM
wayfaringrob
Honored Contributor

Hi all, I have a feature service that once upon a time I had enabled editor tracking. Each feature does indeed have a creator, editor, and timestamp, but at some point I must have turned the tracking off. I'm looking to re-enable tracking, but when I do this, instead of using the existing fields for Creator, CreationDate, etc. it added fields of Creator_1 and CreatonDate_1 and so on, populating them with the current time and my username. This is undesired -- I'd really just like it to keep the existing fields (and their values) and overwrite them next time they are changed. As owner of the data, is there an easy way to do this?

rburke_0-1683237608065.png

 

0 Kudos
7 Replies
Clubdebambos
Frequent Contributor

Hi @wayfaringrob 

What steps did you use to re-enable the editor tracking?

~ learn.finaldraftmapping.com
0 Kudos
wayfaringrob
Honored Contributor

I went to the feature layer's settings in AGO and turned it on.

0 Kudos
Clubdebambos
Frequent Contributor

I thought so alright. When I do this it works perfectly fine and re-instates the Editor Tracking fields. Long shot, but you can try the script below to see if you can update the JSON definition. Update the name of your fields in the dictionary if necessary, add in you feature service id, and point to the correct layer. Im not sure if all entries in the JSON can be updated this way. But at least you can rule out this approach. If it works you can then delete the newly created fields.

from arcgis import GIS

agol = GIS("home")

item = agol.content.get("AGOL_ITEM_ID")

## access the appropriate layer in the feature service
fl = item.layers[0]

## print properties and look for editFieldsInfo
print(fl.properties)

fl_update_dict = {
 "editFieldsInfo": {
    "creationDateField": "CreationDate",
    "creatorField": "CreatedBy",
    "editDateField": "EditedDate",
    "editorField": "EditedBy"
  }
}

## update definition, you can comment this out and re-run o print out definition
## to see if it has been updated.
fl.manager.update_definition(fl_update_dict)

 

~ learn.finaldraftmapping.com
0 Kudos
RhettZufelt
MVP Notable Contributor

Just bringing this back up to see if anyone has found a solution for this?

R_

0 Kudos
wayfaringrob
Honored Contributor

The previous suggestion involving editing the JSON may work but I have not tried it.

0 Kudos
RhettZufelt
MVP Notable Contributor

Unfortunatly, this seems to be a field that ESRI doesn't allow editing...

Both the update definition in the REST, and the script reports 'Success', but no changes made.

R_

RebeccaLoiselle
New Contributor

There is a geoprocessing tool called Enable Editor Tracking which allows you to specify the fields you prefer to use.

https://support.esri.com/en-us/knowledge-base/how-to-edit-or-modify-the-editor-tracking-fields-for-h...

Tags (2)
0 Kudos