ArcGIS REST API Add Features with Editor Tracking Disabled

1963
6
Jump to solution
11-02-2016 12:53 PM
CallumSmith2
Occasional Contributor

Background

We have a growing number of Survey 123 apps that are published to our Portal (10.3.1) with associated Hosted Feature services. As time goes on requirements for changes (new fields) to the surveys become apparent which requires creating a new instance of the survey with a new hosted feature service. What we want to be able to do is push the data from the old survey feature service to the new survey feature service including persisting the editor tracking data.

Methodology

We have decided to use python and the ArcGIS Rest API with the following methodology:

  1. Use "Query" to read the features form the OLD hosted feature service
  2. Use "AddFeatures" to write the features to the NEW hosted feature service

In theory the data from all matching fields will be copied over and any new fields in the new hosted feature service will not be populated.

The Problem

In essence the above methodology works fine. The problem however is with the Editor Tracking fields 

  • created_user ( alias: created_user , length: 255 , nullable: true , type: esriFieldTypeString , editable: false )
  • created_date ( alias: created_date , length: 29 , nullable: true , type: esriFieldTypeDate , editable: false )
  • last_edited_user ( alias: last_edited_user , length: 255 , nullable: true , type: esriFieldTypeString , editable: false )
  • last_edited_date ( alias: last_edited_date , length: 29 , nullable: true , type: esriFieldTypeDate , editable: false )

We want the data in the editor tracking fields in the old service written to the new service

If we leave editor tracking enabled and run the script to copy the data from the old service to the new service the editor fields are populated with the current user and date/time as when the script was run.

If we disable editor tracking the editor tracking fields are not populated at all??

I can see the editor tracking fields in the json returned by the "Query" request and this is being passed to the "AddFeatures" request. The data is not populated in the new service but all other data is?

Is there a way to populate editor tracking fields in a hosted feature service with data other than have them automatically populate with current user current date/time etc?

If anybody has come across this issue and has a valid solution that would be much appreciated.

cheers

Callum

0 Kudos
1 Solution

Accepted Solutions
CallumSmith2
Occasional Contributor

I have managed to figure out the issue. The editor tracking fields editing capability is disabled. Even when editor tracking is disabled these fields are still not editable! Dont know why I didn't notice that earlier...

  • created_user ( alias: created_user , length: 255 , nullable: true , type: esriFieldTypeString , editable: false )
  • created_date ( alias: created_date , length: 29 , nullable: true , type: esriFieldTypeDate , editable: false )
  • last_edited_user ( alias: last_edited_user , length: 255 , nullable: true , type: esriFieldTypeString , editable: false )
  • last_edited_date ( alias: last_edited_date , length: 29 , nullable: true , type: esriFieldTypeDate , editable: false )

So what I had do as part of my script is disable editor tracking and then enable editing on the fields using a UpdateDefinition Request.

Hope this helps someone else

cheers

Callum

View solution in original post

6 Replies
CallumSmith2
Occasional Contributor

I have managed to figure out the issue. The editor tracking fields editing capability is disabled. Even when editor tracking is disabled these fields are still not editable! Dont know why I didn't notice that earlier...

  • created_user ( alias: created_user , length: 255 , nullable: true , type: esriFieldTypeString , editable: false )
  • created_date ( alias: created_date , length: 29 , nullable: true , type: esriFieldTypeDate , editable: false )
  • last_edited_user ( alias: last_edited_user , length: 255 , nullable: true , type: esriFieldTypeString , editable: false )
  • last_edited_date ( alias: last_edited_date , length: 29 , nullable: true , type: esriFieldTypeDate , editable: false )

So what I had do as part of my script is disable editor tracking and then enable editing on the fields using a UpdateDefinition Request.

Hope this helps someone else

cheers

Callum

GregoryGasteratos
New Contributor II

Can you share the code please. I have the same issue.

0 Kudos
CallumSmith2
Occasional Contributor

Hi Gregory

Sorry I missed your post. Are you still having issues? Do you still want the code?

Callum

GregoryGasteratos
New Contributor II

Yes please! The code would be very useful.

Thanks,

Greg.

CallumSmith2
Occasional Contributor

Hi Gregory

This may or may not help you sorry. Our scripts are split into modules for reuse so I can give you everything. Attached is the base script which should help you with the workflow we used (without too much of the detail sorry) I also wrote this a few years back so there may be netter ways of achieving this now with the ArcGIS api for python

Callum

0 Kudos
GregoryGasteratos
New Contributor II

Many thanks

0 Kudos