AnsweredAssumed Answered

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

Question asked by Koelker12 on Feb 4, 2019
Latest reply on Apr 8, 2019 by Koelker12

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!