<?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 Re: Preserve GlobalIDs with arcpy.da.InsertCursor in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1354262#M44814</link>
    <description>&lt;P&gt;The long answer is that you might be able to use the fid returned by &lt;FONT face="courier new,courier"&gt;arcpy.da.InsertCursor.insertRow()&lt;/FONT&gt; to build a dictionary (&lt;FONT face="courier new,courier"&gt;lookup[fid] = old_globalid&lt;/FONT&gt;), then use the created fid in a DA UpdateCursor pass to update the uuid value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;updated = 0
with arcpy.da.UpdateCursor(fc,['objectid','globalid']) as cursor:
    for row in cursor:
        if row[0] in lookup:
            cursor.updateRow([row[0],lookup[row[0]])
            updated += 1
print("{:d} globalid values updated".format(updated))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This could only work &lt;EM&gt;because&lt;/EM&gt; cursors ignore GlobalID values. I haven't tested this, but it's worth a shot.&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;&lt;P&gt;PS: Oh, and there exists a chance (however slight) that one of the new UUIDs could conflict with&amp;nbsp; a replacement GlobalID value, though it's&amp;nbsp; so slight that you probably don't need to check first (but if it does occur, then the global dictionary in memory will be lost by the error).&lt;/P&gt;</description>
    <pubDate>Tue, 28 Nov 2023 19:22:56 GMT</pubDate>
    <dc:creator>VinceAngelo</dc:creator>
    <dc:date>2023-11-28T19:22:56Z</dc:date>
    <item>
      <title>Preserve GlobalIDs with arcpy.da.InsertCursor</title>
      <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353061#M44803</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is it possible to preserve the GlobalIDs using&amp;nbsp;&lt;EM&gt;arcpy.da.InsertCursor()&lt;/EM&gt;?&lt;BR /&gt;&lt;BR /&gt;I have an SDE database, &lt;EM&gt;arcpy.env.preserveGlobalIds = True&lt;/EM&gt; and when I use Append to copy the data, GlobalIDs come through and match the source datasetas they should.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I use&amp;nbsp;&lt;EM&gt;arcpy.da.InsertCursor()&lt;/EM&gt;, GlobalIDs get replaced with the new ones.&lt;/P&gt;&lt;P&gt;Does&amp;nbsp;&lt;EM&gt;preserveGlobalIds&lt;/EM&gt;&amp;nbsp;setting work just for Append? Is it the way to make the Cursor respect this setting?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 23:26:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353061#M44803</guid>
      <dc:creator>EM-wsp</dc:creator>
      <dc:date>2023-11-23T23:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve GlobalIDs with arcpy.da.InsertCursor</title>
      <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353067#M44804</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/environment-settings/an-overview-of-geoprocessing-environment-settings.htm" target="_blank"&gt;An overview of geoprocessing environment settings—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I think the operative word is "Tools".&amp;nbsp; arcpy.da is a package and has no tools associated with it.&lt;/P&gt;&lt;P&gt;making a copy of existing values would at least provide you with a backup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Geodatabase Advanced environments&lt;BR /&gt;Environment Description&lt;BR /&gt;Preserve Global IDs&lt;/P&gt;&lt;P&gt;Tools that honor the Preserve Global IDs environment will reuse the Global ID values of the existing input dataset when appending rows to a target dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2023 00:54:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353067#M44804</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-11-24T00:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve GlobalIDs with arcpy.da.InsertCursor</title>
      <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353197#M44805</link>
      <description>&lt;P&gt;Hi!&lt;BR /&gt;Thank you&amp;nbsp; for your reply! I understand now why environmental setting is ignored by the Cursor.&lt;/P&gt;&lt;P&gt;But is there any way to get globalids preserved with the InsertCursor? I tried to apply UpdateCursor as well after inserting, but with no success. The tool doesn't complain or fail, it even takes some time to run, but the GlobalIDs are still new.&lt;/P&gt;&lt;P&gt;Since the in-built tools (Append, Copy etc) can have it preserved, the database apparently has this functionality. Can it be somehow set up in the Cursor functions?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2023 17:48:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353197#M44805</guid>
      <dc:creator>EM-wsp</dc:creator>
      <dc:date>2023-11-24T17:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve GlobalIDs with arcpy.da.InsertCursor</title>
      <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353207#M44806</link>
      <description>&lt;P&gt;No is the short answer.&amp;nbsp; Geoprocessing Tools have environments&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2023 18:53:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353207#M44806</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-11-24T18:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve GlobalIDs with arcpy.da.InsertCursor</title>
      <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353245#M44807</link>
      <description>&lt;P&gt;Ok, thank you. At least I got it confirmed.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2023 21:42:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1353245#M44807</guid>
      <dc:creator>EM-wsp</dc:creator>
      <dc:date>2023-11-24T21:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve GlobalIDs with arcpy.da.InsertCursor</title>
      <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1354262#M44814</link>
      <description>&lt;P&gt;The long answer is that you might be able to use the fid returned by &lt;FONT face="courier new,courier"&gt;arcpy.da.InsertCursor.insertRow()&lt;/FONT&gt; to build a dictionary (&lt;FONT face="courier new,courier"&gt;lookup[fid] = old_globalid&lt;/FONT&gt;), then use the created fid in a DA UpdateCursor pass to update the uuid value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;updated = 0
with arcpy.da.UpdateCursor(fc,['objectid','globalid']) as cursor:
    for row in cursor:
        if row[0] in lookup:
            cursor.updateRow([row[0],lookup[row[0]])
            updated += 1
print("{:d} globalid values updated".format(updated))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This could only work &lt;EM&gt;because&lt;/EM&gt; cursors ignore GlobalID values. I haven't tested this, but it's worth a shot.&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;&lt;P&gt;PS: Oh, and there exists a chance (however slight) that one of the new UUIDs could conflict with&amp;nbsp; a replacement GlobalID value, though it's&amp;nbsp; so slight that you probably don't need to check first (but if it does occur, then the global dictionary in memory will be lost by the error).&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 19:22:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1354262#M44814</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2023-11-28T19:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve GlobalIDs with arcpy.da.InsertCursor</title>
      <link>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1354459#M44817</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;I had tested exactly the same approch before creating this post, and it didn't work. We can conclude that neither InsertCursor, nor UpdateCursor are able to modify GlobalIDs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 01:07:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/preserve-globalids-with-arcpy-da-insertcursor/m-p/1354459#M44817</guid>
      <dc:creator>EM-wsp</dc:creator>
      <dc:date>2023-11-29T01:07:13Z</dc:date>
    </item>
  </channel>
</rss>

