<?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 Pull Attachments Table from AGOL in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1512904#M45299</link>
    <description>&lt;P&gt;Hey All,&lt;/P&gt;&lt;P&gt;I have recently been asked to create a sync between AGOL and a local database, this is a relatively simple task with a combination of ArcGIS API for Python and ArcPy since ArcPy cannot communicate with AGOL.&lt;/P&gt;&lt;P&gt;The issue arises now because there are attachments, when I exported the feature layer to a FGDB I see this here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CodyPatterson_0-1722431248331.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111186i97FEADF196CED3EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CodyPatterson_0-1722431248331.png" alt="CodyPatterson_0-1722431248331.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I see that there is a relationship and an ATTACH table, I found that the relationship can be entered once and left without issue, but I need to update the ATTACH table for the attachments in the feature classes to be included, how can I extract this ATTACH table or possibly the attachments to format into the table?&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2024 13:08:52 GMT</pubDate>
    <dc:creator>CodyPatterson</dc:creator>
    <dc:date>2024-07-31T13:08:52Z</dc:date>
    <item>
      <title>Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1512904#M45299</link>
      <description>&lt;P&gt;Hey All,&lt;/P&gt;&lt;P&gt;I have recently been asked to create a sync between AGOL and a local database, this is a relatively simple task with a combination of ArcGIS API for Python and ArcPy since ArcPy cannot communicate with AGOL.&lt;/P&gt;&lt;P&gt;The issue arises now because there are attachments, when I exported the feature layer to a FGDB I see this here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CodyPatterson_0-1722431248331.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111186i97FEADF196CED3EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CodyPatterson_0-1722431248331.png" alt="CodyPatterson_0-1722431248331.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I see that there is a relationship and an ATTACH table, I found that the relationship can be entered once and left without issue, but I need to update the ATTACH table for the attachments in the feature classes to be included, how can I extract this ATTACH table or possibly the attachments to format into the table?&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 13:08:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1512904#M45299</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-07-31T13:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1512988#M45301</link>
      <description>&lt;P&gt;To sync from AGOL data to the local database, I have been using the arcpy.management.Append with preserve GlobalIds and maintain Attachments.&lt;/P&gt;&lt;P&gt;Then I get an updated local copy of the data with attachments while preserving the GlobalIds.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 15:12:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1512988#M45301</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-07-31T15:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1513536#M45302</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately it seems that ArcPy is not reliable with AGOL according to BUG-000144037 which is not planned to be fixed unfortunately, I ended up setting up a macro on a server to make clicks which downloaded the FGDB, and then ran the script after it was export from AGOL, which then is deleted afterward.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 11:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1513536#M45302</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-01T11:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1513747#M45311</link>
      <description>&lt;P&gt;Not sure if you are trying to sync both ways, or why you are wanting to use the&amp;nbsp;arcpy.MakeFeatureLayer_management as the bug references, but maybe my process is different enough it won't work for you.&lt;/P&gt;&lt;P&gt;In my case, I have a local eGDB that I published to AGOL for data collection in a Field Maps app.&lt;/P&gt;&lt;P&gt;So, the data is collected in AGOL hosted feature service, but I need to keep the local copy up to date.&lt;/P&gt;&lt;P&gt;I have been using code similar to the following for the last 2 years and have had no issues with it.&lt;/P&gt;&lt;P&gt;Basically, I establish a search cursor on the AGOL and local datasets and load the GlobalIDs into a list.&amp;nbsp; It also compares the two lists, and if there are GlobalIDs in the AGOL list, but not the local list, it means those features need to be copied (appended) over. (So, we are only coping the 'missing' features, not the entire dataset)&lt;/P&gt;&lt;P&gt;Then I use&amp;nbsp;arcpy.management.Append to append the missing features to the local data using a where clause that is an IN() with the GlobalID's from the missing list like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

Signs = r'\\path_to\\SignDatabase.sde\SignsDatabase.DBO.Signs'  # path to the signs local eGDB FC
L0Sign = r"https://services3.arcgis.com/itemID/ArcGIS/rest/services/HostedFeatureService/FeatureServer/0" # URL to AGOL hosted feature

AGOL_SignTable =  arcpy.FeatureSet()  # define AGOL_SignTable as FeatureSet
AGOL_SignTable.load(L0Sign)                # Load hosted feature into AGOL_SignTable

SignList = []       # empty list for local GDB features
AGOLSignList = []   # empty list for AGOL features


with arcpy.da.SearchCursor(Signs,"GlobalID") as cursor:           # Get list of GlobalID's from SDE data
    for row in cursor:
        SignList.append(row[0])

with arcpy.da.SearchCursor(AGOL_SignTable,"GlobalID") as cursor:  # Get list of GlobalID's from AGOL data
    for row in cursor:                                      
        AGOLSignList.append(row[0].upper())
        if (row[0].upper() or row[0]) not in SignList:             # and if not in local SignList, append to AddSignList
           AddSignList.append(row[0])


ith arcpy.EnvManager(preserveGlobalIds=True, maintainAttachments = True): 
    if AddSignList:                                                 # if any 'missing' features in AddSignList, then append to local eGDB
       print("adding " + str(len(AddSignList)) + " Sign Records")
       Signs = arcpy.management.Append(inputs=[L0Sign], target=Signs, schema_type="TEST", field_mapping="", subtype="", expression="GlobalID IN ('" + '\',\''.join(AddSignList) + "')")[0]
    else:
       print("No Signs to add")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't say the same for any scripts I run using the API python (seem to get a lot of timeout errors, etc. and have to code accordingly).&amp;nbsp; However, I have had good success with the &lt;A href="https://community.esri.com/t5/arcgis-online-questions/how-to-create-hosted-feature-layer-backups/m-p/1419497/highlight/true#M59065" target="_self"&gt;API code here&lt;/A&gt; to export an AGOL hosted feature service to a FGDB (including attachments) and download to local folder without having to script any mouse clicks.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 15:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1513747#M45311</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-08-05T15:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1514098#M45315</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the informative response and code, I attempted to copy the code exactly as you mentioned, but I'm not sure what the SignTable function should represent. The reason behind the makefeaturelayer function is due to geoprocessing tools that need to run on the hosted feature service. Attempting to load the layer into an FGDB does not work as well, currently, the main issue is getting ArcPy and AGOL to talk in any extent, the support technician I worked with stated that it's a known limitation that these aren't working, but work for some just fine, and ESRI is not interesting in pursuing the fix further, as the bug mentions unfortunately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 11:22:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1514098#M45315</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-02T11:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1515006#M45318</link>
      <description>&lt;P&gt;If you copied it exactly, not surprising you got an error as I had a mistake in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;AGOL_SignTable =  arcpy.FeatureSet()
AGOL_SignTable.load(L0Sign)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I define AGOL_SignTable as an&amp;nbsp; arcpy feature set, then the next line loads the data from the hosted feature server layer URL into the arcpy FeatureSet.&lt;/P&gt;&lt;P&gt;Once loaded, I can treat AGOL_SignTable as any other FGDB featureclass.&amp;nbsp; I have not tested all functions on it, but works well with search cursors, arcpy calculate and arcpy append.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 19:42:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1515006#M45318</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-08-05T19:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1515098#M45319</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my output here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CodyPatterson_0-1722881783887.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111634i1D92C4F66A0D077F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CodyPatterson_0-1722881783887.png" alt="CodyPatterson_0-1722881783887.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

layer_name = r"https://services9.arcgis.com/{id}/arcgis/rest/services/USA_Counties_6260724028191129561/FeatureServer"

AGOL_SignTable =  arcpy.FeatureSet()
AGOL_SignTable.load(layer_name)&lt;/LI-CODE&gt;&lt;P&gt;This was another error that was mentioned to only work for some, and not others.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 18:17:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1515098#M45319</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-05T18:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1515152#M45320</link>
      <description>&lt;P&gt;What happens is you use the full path to the feature layer in that feature service (add the correct layer number to the end of the URL.&amp;nbsp; /0 on my HFS)?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;layer_name = r"https://services9.arcgis.com/{id}/arcgis/rest/services/USA_Counties_6260724028191129561/FeatureServer/0"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 19:44:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1515152#M45320</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-08-05T19:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1516010#M45321</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, the exact same error came through. Not sure why my AGOL and ArcPy are so incompatible, but maybe I'm just missing something!&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 11:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1516010#M45321</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-07T11:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Attachments Table from AGOL</title>
      <link>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1516129#M45323</link>
      <description>&lt;P&gt;Not sure what to tell you.&amp;nbsp; I have tested on my end with polygon and point feature classes with no issue.&lt;/P&gt;&lt;P&gt;Perhaps there is a limitation on the Feature Service you are connecting to.&amp;nbsp; I published my own HFS with no restrictions and use the code to keep the local data in sync with changes to the HFS.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 14:56:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/pull-attachments-table-from-agol/m-p/1516129#M45323</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-08-07T14:56:40Z</dc:date>
    </item>
  </channel>
</rss>

