Select to view content in your preferred language

How to preserve editor values when performing regular automated updates

160
4
Friday
eberlin_dffm
New Contributor

I have a hosted feature layer with several feature layer views. These feature layers are used regularly for day to day operations. I'd like to perform nightly geospatial calculations on the hosted feature layer (e.g. centroid coordinates, GIS acres, etc.), but from my experience that updates the LastEditor and LastEdited field with my information. 

Is there a way to perform automated updates without impacting the editor values? 

0 Kudos
4 Replies
abdhassa24
Emerging Contributor

Don't think there is a way, you would have to create your own static editor tracking fields and update them when doing your day to day operations

0 Kudos
eberlin_dffm
New Contributor

That wouldn't work because we have many different users using these feature layers on ArcPro, Field Maps, and AGOL browser apps. We can't count on each user manually updating the editor fields every time they update a feature. 

0 Kudos
abdhassa24
Emerging Contributor

Perhaps you can use the Arcade Expression GetUser().username in Map Viewer Forms to automatically populate Creator, Last Editor and another Arcade Expression to retrieve Current Date to use for Creation Date, Last Edited Date

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hi @eberlin_dffm,

You could disable editing tracking, perform your calculations, then re-enable editor tracking.  Below is an example using python:

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

# Connect to AGOL/Portal
print("Connecting to AGOL/Portal")
gis = GIS('https://www.arcgis.com', 'jskinner_rats', 'secureP@ssword')

# Reference item
print("Referencing item")
item = gis.content.get('4021d79d47854ef19f08ef902354bc99')
sourceFlyrCollection = FeatureLayerCollection.fromitem(item)

# Disable editor tracking params
editor_tracking_params = {
    "enableEditorTracking": False
}

# Update definition
print("Disable editor tracking")
update_result = sourceFlyrCollection.manager.update_definition({"editorTrackingInfo": editor_tracking_params})
print(update_result)

# Perform calculations

# Enable editor tracking params
editor_tracking_params = {
    "enableEditorTracking": True,
    "createrField": "Creator",
    "creationDateField": "CreationDate",
    "editorField": "Editor",
    "editDateField": "EditDate"
}

# Update definition
print("Enable editor tracking")
update_result = sourceFlyrCollection.manager.update_definition({"editorTrackingInfo": editor_tracking_params})
print(update_result)