<?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 Updating SDE Using AGOL Layers in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/updating-sde-using-agol-layers/m-p/1274619#M35556</link>
    <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;When I set up a new geodatabase for field collection a couple years ago I may have did it a bit backwards. Instead of uploading the layers to ArcGIS Server and then using that layer to collect data using Field Maps, I uploaded it straight to AGOL and began collecting data using the AGOL layer. This feature layer has 19 sublayers associated with it and all have attachments.&lt;/P&gt;&lt;P&gt;After more than 5,000 features collected, I need to get these data into our SDE and have it continuously updated as new features are added. The data also has domains and subtypes.&lt;/P&gt;&lt;P&gt;I have tried to export the layers as a FGDB, but AGOL will never finish the download (it just spins like it's working but never finishes). When I import the AGOL layer into ArcGIS Pro, the domains don't come over with it.&lt;/P&gt;&lt;P&gt;What would be the best way to be able pull data from AGOL and update our SDE using that data?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Apr 2023 12:32:35 GMT</pubDate>
    <dc:creator>JoshBillings</dc:creator>
    <dc:date>2023-04-03T12:32:35Z</dc:date>
    <item>
      <title>Updating SDE Using AGOL Layers</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/updating-sde-using-agol-layers/m-p/1274619#M35556</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;When I set up a new geodatabase for field collection a couple years ago I may have did it a bit backwards. Instead of uploading the layers to ArcGIS Server and then using that layer to collect data using Field Maps, I uploaded it straight to AGOL and began collecting data using the AGOL layer. This feature layer has 19 sublayers associated with it and all have attachments.&lt;/P&gt;&lt;P&gt;After more than 5,000 features collected, I need to get these data into our SDE and have it continuously updated as new features are added. The data also has domains and subtypes.&lt;/P&gt;&lt;P&gt;I have tried to export the layers as a FGDB, but AGOL will never finish the download (it just spins like it's working but never finishes). When I import the AGOL layer into ArcGIS Pro, the domains don't come over with it.&lt;/P&gt;&lt;P&gt;What would be the best way to be able pull data from AGOL and update our SDE using that data?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 12:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/updating-sde-using-agol-layers/m-p/1274619#M35556</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2023-04-03T12:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Updating SDE Using AGOL Layers</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/updating-sde-using-agol-layers/m-p/1274686#M35569</link>
      <description>&lt;P&gt;I'd suggest using the ArcGIS Python API. With it, you could easily query the AGOL service and push edits to your SDE. Easiest if the SDE layer is also a published service, and if you have editor tracking enabled, all the better.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcgis

gis = arcgis.GIS('your portal url', 'user', 'password')

hosted = gis.content.get('itemid of your field layer').layers[0] # assuming it's layer index 0, but it could be something else

sde = gis.content.get('itemid of published sde layer').layers[0]

# get recent edits
date_range = '07'
recent_edits = hosted.query(where=f"last_edited_date &amp;gt; NOW() - INTERVAL '{date_range}' DAY AND created_date &amp;lt; NOW() - INTERVAL '{date_range}' DAY")

# get recent adds
recent_adds = hosted.query(where=f"created_date &amp;gt; NOW() - INTERVAL '{date_range}' DAY")

# possible reshaping of schema here

sde.edit_features(adds=recent_adds, updates=recent_edits)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll probably need some way of identifying deletes, if features are deleted on the AGOL side. And to successfully apply the &lt;STRONG&gt;updates&lt;/STRONG&gt; portion, you need some way of reliably linking objects in one table with those in another. I'd suggest adding a GUID field to one or both tables for this purpose.&lt;/P&gt;&lt;P&gt;Alternatively, you could just truncate the SDE table and use the AGOL data to load in a fresh set of data. Simpler, but more time-consuming.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 14:20:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/updating-sde-using-agol-layers/m-p/1274686#M35569</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-04-03T14:20:00Z</dc:date>
    </item>
  </channel>
</rss>

