<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Enable Editing &amp;amp; Editor Tracking via Python API in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/enable-editing-amp-editor-tracking-via-python-api/m-p/1071488#M61460</link>
    <description>&lt;P&gt;Still struggling a bit with the FeatureLayerManager class and when to use &lt;FONT face="courier new,courier"&gt;add_to_defintion&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;updateDefinition&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;delete_from_definition&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;This time, I am trying to enable editing and editor tracking on a hosted feature service. I started by opening up the Chrome developer tools Network monitor, then on the Feature Layer settings page I manually checked the options 'Enable editing', 'Keep track of created and updated features' and 'Keep track of who created and last updated features', then hit Save. I then saw the console send an update_definition request.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="updateDefinition.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16582i44E8BA9D0595CF11/image-size/large?v=v2&amp;amp;px=999" role="button" title="updateDefinition.PNG" alt="updateDefinition.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I copied the form data and popped that into my update_definition method in my python notebook&amp;nbsp;@ line 13&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Convert to a Spatially Enabled Dataframe
sdf = pd.DataFrame.spatial.from_xy(df, "lon_y", "lat_x", sr=4326)

print('Publishing layer...')
item = sdf.spatial.to_featurelayer('myFeatureLayer', tags=["test"], folder="My Folder")
print("Deleting interim fGDB...")
interimGDB = gis.content.get(gis.content.search(query="title:myFeatureLayer", item_type="File Geodatabase")[0].id).delete()
featureLayer = gis.content.get(item.id).layers[0]

print("Enabling Change Tracking...")
resp = featureLayer.manager.update_definition({
    "hasStaticData":False,
    "capabilities": "Query, Editing, Create, Update, Delete, ChangeTracking",
    "editorTrackingInfo":{
        "enableEditorTracking":True,
        "enableOwnershipAccessControl":False,
        "allowOthersToUpdate":True,
        "allowOthersToDelete":True,
        "allowOthersToQuery":True,
        "allowAnonymousToUpdate":True,
        "allowAnonymousToDelete":True}
    })
print(resp)
print(featureLayer.properties)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reviewing the properties/definition however, I noticed that under nothing in the definition actually was updated, other than 'hasStaticData' which was changed from False to True. 'ChangeTracking' is not listed as a capability and the editorTrackingInfo array is not present in the updated definition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 14:38:20 GMT</pubDate>
    <dc:creator>JohnMDye</dc:creator>
    <dc:date>2021-06-23T14:38:20Z</dc:date>
    <item>
      <title>Enable Editing &amp; Editor Tracking via Python API</title>
      <link>https://community.esri.com/t5/python-questions/enable-editing-amp-editor-tracking-via-python-api/m-p/1071488#M61460</link>
      <description>&lt;P&gt;Still struggling a bit with the FeatureLayerManager class and when to use &lt;FONT face="courier new,courier"&gt;add_to_defintion&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;updateDefinition&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;delete_from_definition&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;This time, I am trying to enable editing and editor tracking on a hosted feature service. I started by opening up the Chrome developer tools Network monitor, then on the Feature Layer settings page I manually checked the options 'Enable editing', 'Keep track of created and updated features' and 'Keep track of who created and last updated features', then hit Save. I then saw the console send an update_definition request.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="updateDefinition.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16582i44E8BA9D0595CF11/image-size/large?v=v2&amp;amp;px=999" role="button" title="updateDefinition.PNG" alt="updateDefinition.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I copied the form data and popped that into my update_definition method in my python notebook&amp;nbsp;@ line 13&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Convert to a Spatially Enabled Dataframe
sdf = pd.DataFrame.spatial.from_xy(df, "lon_y", "lat_x", sr=4326)

print('Publishing layer...')
item = sdf.spatial.to_featurelayer('myFeatureLayer', tags=["test"], folder="My Folder")
print("Deleting interim fGDB...")
interimGDB = gis.content.get(gis.content.search(query="title:myFeatureLayer", item_type="File Geodatabase")[0].id).delete()
featureLayer = gis.content.get(item.id).layers[0]

print("Enabling Change Tracking...")
resp = featureLayer.manager.update_definition({
    "hasStaticData":False,
    "capabilities": "Query, Editing, Create, Update, Delete, ChangeTracking",
    "editorTrackingInfo":{
        "enableEditorTracking":True,
        "enableOwnershipAccessControl":False,
        "allowOthersToUpdate":True,
        "allowOthersToDelete":True,
        "allowOthersToQuery":True,
        "allowAnonymousToUpdate":True,
        "allowAnonymousToDelete":True}
    })
print(resp)
print(featureLayer.properties)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reviewing the properties/definition however, I noticed that under nothing in the definition actually was updated, other than 'hasStaticData' which was changed from False to True. 'ChangeTracking' is not listed as a capability and the editorTrackingInfo array is not present in the updated definition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 14:38:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/enable-editing-amp-editor-tracking-via-python-api/m-p/1071488#M61460</guid>
      <dc:creator>JohnMDye</dc:creator>
      <dc:date>2021-06-23T14:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Enable Editing &amp; Editor Tracking via Python API</title>
      <link>https://community.esri.com/t5/python-questions/enable-editing-amp-editor-tracking-via-python-api/m-p/1083167#M61872</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed you're trying to enable editing on a FeatureLayer, but you want to be enabling it on the FeatureLayerCollection since it's a service-level property. Can you report back what happens when you update the flc?&lt;/P&gt;&lt;P&gt;The below works perfectly for me:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
from arcgis.features import eatureLayerCollection

gis = GIS("https://www.arcgis.com", "username", "password")
url = "https://your/server/url/FeatureServer"
flc = FeatureLayerCollection(url, gis=gis)

edit_dict = {
    "hasStaticData":False,
    "capabilities": "Query, Editing, Create, Update, Delete, ChangeTracking",
    "editorTrackingInfo":{
        "enableEditorTracking":True,
        "enableOwnershipAccessControl":False,
        "allowOthersToUpdate":True,
        "allowOthersToDelete":True,
        "allowOthersToQuery":True,
        "allowAnonymousToUpdate":True,
        "allowAnonymousToDelete":True}
    }
flc.manager.update_definition(edit_dict)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 27 Jul 2021 18:25:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/enable-editing-amp-editor-tracking-via-python-api/m-p/1083167#M61872</guid>
      <dc:creator>emedina</dc:creator>
      <dc:date>2021-07-27T18:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Enable Editing &amp; Editor Tracking via Python API</title>
      <link>https://community.esri.com/t5/python-questions/enable-editing-amp-editor-tracking-via-python-api/m-p/1084488#M61903</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/429833"&gt;@emedina&lt;/a&gt;! With your guidance, I was able to get it to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's interesting, apparently&amp;nbsp; the gis parameter on FeatureLayerCollection is not so optional. If I left it off, I would get errors, even though the GIS object is already instantiated in a previous cell.&lt;/P&gt;&lt;P&gt;The other thing I thought was unexpected was that simply using the featureLayer.url would not suffice because that resolves to the first layer in the collection (eg. .../FeatureServer/0), but it actually needs the Collection so I had to use featureLayer.container.url.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 16:43:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/enable-editing-amp-editor-tracking-via-python-api/m-p/1084488#M61903</guid>
      <dc:creator>JohnMDye</dc:creator>
      <dc:date>2021-07-30T16:43:33Z</dc:date>
    </item>
  </channel>
</rss>

