Select to view content in your preferred language

How to designate Editor Tracking Fields when overwriting a service using ArcGIS Online Python API

02-04-2019 03:47 PM
Occasional Contributor III

Hey all,

Currently in a jam with a python script that achieves the following workflow. Have succeeded in everything but the final step:

  1. Turn off editor tracking for hosted feature service X in ArcGIS Online. Feature X is a table of facilities with some status fields that are updated by staff through Collector.
  2. Pull down copy of feature X to a fgdb on local machine.
  3. Join status and editor tracking fields from feature X to a new feature Y. Feature Y is an updated list of facilities generated from an Oracle database (new facilities may have opened or some may have closed).
  4. Using a combo of this and this, create a draft Service Definition using a Pro project (.aprx) that contains the newly updated Feature Y.
  5. Create Service Definition file from that draft, then overwrite the Service Definition item of feature X in ArcGIS Online using .update()
  6. Republish/overwrite feature X using .publish(overwrite=True,file_type="serviceDefinition"), which carries over the changes from the updated Service Definition.
  7. Re-enable editor tracking for feature X, BUT use the existing editor fields joined to feature Y during Step 3.

I am able to successfully re-enable editor tracking of the hosted feature, but instead of using the existing editor-tracking fields (Creator, CreationDate, Editor, EditDate) it creates a new set (Create_1, CreationDate_1, Editor_1, and EditDate_1). I've tried designating the fields while using update_definition() with something like:

"editFieldsInfo" : {
 "creationDateField" : "CreationDate",
 "creatorField" : "Creator",
 "editDateField" : "EditDate",
 "editorField" : "Editor"

...but it seems to ignore that. I've also tried setting {"preserveEditUsersAndTimestamps":True} both when disabling and enabling the editor tracking, but there's no effect I can see. Any idea how to control this? It's easy to set them manually with the arcpy tools in Desktop, but if I do that I'm unable to upload the feature to ArcGIS Online. If I enable and then disable with arcpy prior to upload, it doesn't remember those fields once I enable in ArcGIS Online via update_definition(). Thought maybe it should go into the draft service definition, but there's nothing about that in the documentation. I've attached a snippet of the upload and enabling process I currently have at the end of my script.

Please help!  


2 Replies
Occasional Contributor III

Can any ESRI staff confirm if this is even possible? We've given up on trying to retain the editor tracking info for this particular project (and have found a new problem in disabling/enabling editor tracking when there are feature views involved), but am still curious of this process for use with future workflows. 


Occasional Contributor III

In case anyone stumbles across this later... still haven't figured out how to designate existing editor tracking fields when uploading/overwriting a hosted feature layer. However we did manage to overwrite a hosted feature layer that had editable views (with editor tracking) by disabling via an definition update in a specific order, since editing, tracking who and tracking when, and sync capabilities have certain two-way dependencies on one another. So first turn off editing (box 1 below), change-tracking (box 2 on editing settings, last-edited-on), and sync (box 4) for the views all at once -- then turn off change-tracking (2), editor-tracking (box 3 in editing settings, last-edited-by),and sync (4) for the source hosted feature layer. Then disable editing (box 1) for the source hosted feature layer. You don't have to disable box 3/last-edited-by on the views after this. Then after you finish overwriting your hosted feature layer, you go in reverse, but turn on everything for the source hosted feature layer at once (1,2,3,4), and then turn on editing (1), change-tracking (box 2/lasted-edited-by) and sync (4) for the views. Box 3/editortracking/last-edited-by on the views will take care of itself. 

  • box 1 controlled by "Editing" under capabilities in service definition.
  • box 2 controlled by "ChangeTracking" under capabilities in service definition.
  • box 3 controlled by "enableEditorTracking: True/False" within "editorTrackingInfo" in service definition.
  • box 4 controlled by "Sync" under capabilities in service definition.


Hope this helps someone on the seas of Google.