<?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 InsertCursor return GlobalID in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/insertcursor-return-globalid/m-p/725764#M56238</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Hi&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is there any way using a arcpy.da.insertCursor for it to return a GlobalIID rather than the OBJECTID?&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;My script is adding data to a number of feature classes and tables that are all tied together with relationship classes using GlobalID's and keys. The purpose of my script is to normalise some data in a table that has been captured with Survey123.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Currently my workflow is as follows&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;1. Create a edit session&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;2. Create InsertCursors for all my tables.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;3. Loop through my input adding records to the necessary tables. After Each insert I get the OBJECTID and then create a SearchCursor on the same table with the OBJECTID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as the where. I then extract the GlobalID from the record in the search cursor.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;4. delete Insert Cursors&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;5. Stop editing and Commit.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;This approach works for some of my tables but not for others? My guess there is some kind if issue / bug when triggering a search cursor on a table that is in edit mode on a record that has just been added and not committed?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is there a better approach for this to get a GlobalID from a record that has just been inserted?&amp;nbsp; I don't want to have to stop editing after each insert to create a SearchCursor get the GlobalID as this will potentially be slow.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;cheers&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Callum&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Feb 2018 02:48:08 GMT</pubDate>
    <dc:creator>CallumSmith2</dc:creator>
    <dc:date>2018-02-07T02:48:08Z</dc:date>
    <item>
      <title>InsertCursor return GlobalID</title>
      <link>https://community.esri.com/t5/python-questions/insertcursor-return-globalid/m-p/725764#M56238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Hi&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is there any way using a arcpy.da.insertCursor for it to return a GlobalIID rather than the OBJECTID?&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;My script is adding data to a number of feature classes and tables that are all tied together with relationship classes using GlobalID's and keys. The purpose of my script is to normalise some data in a table that has been captured with Survey123.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Currently my workflow is as follows&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;1. Create a edit session&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;2. Create InsertCursors for all my tables.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;3. Loop through my input adding records to the necessary tables. After Each insert I get the OBJECTID and then create a SearchCursor on the same table with the OBJECTID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as the where. I then extract the GlobalID from the record in the search cursor.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;4. delete Insert Cursors&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;5. Stop editing and Commit.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;This approach works for some of my tables but not for others? My guess there is some kind if issue / bug when triggering a search cursor on a table that is in edit mode on a record that has just been added and not committed?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is there a better approach for this to get a GlobalID from a record that has just been inserted?&amp;nbsp; I don't want to have to stop editing after each insert to create a SearchCursor get the GlobalID as this will potentially be slow.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;cheers&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Callum&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Feb 2018 02:48:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insertcursor-return-globalid/m-p/725764#M56238</guid>
      <dc:creator>CallumSmith2</dc:creator>
      <dc:date>2018-02-07T02:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: InsertCursor return GlobalID</title>
      <link>https://community.esri.com/t5/python-questions/insertcursor-return-globalid/m-p/725765#M56239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have figured out what the issue was here and why I could get the GlobalID for some featureclasses/tables and not others. Consider the following code snippet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'featureclass'&lt;/SPAN&gt;
insertFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'field2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;InsertCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; insertFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; insertCursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; row &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Blah'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Blah'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; objectid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; insertCursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;insertRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp; searchFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'OBJECTID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'GLOBALID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; whereClause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'OBJECTID = {0}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;objectid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; searchFields&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; whereClause&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; searchCursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; searchCursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; globalid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;searchFields&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'GLOBALID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a featureclass I am trying to extract the GlobalID from the record that has just been inserted. This works for some of my featureclasses/tables but not others. After some testing (and hair pulling!) I have identified for the above code to work and return the globalid the featureclass has to participate in a composite relationship class with the globalid as the primary key. If the featureclass does not participate in a composite relationship class then the search cursor will not be able to find the previously inserted record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has a better method of getting the globalid for a record that has just been inserted I would be interested in hearing from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Callum&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:01:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insertcursor-return-globalid/m-p/725765#M56239</guid>
      <dc:creator>CallumSmith2</dc:creator>
      <dc:date>2021-12-12T07:01:58Z</dc:date>
    </item>
  </channel>
</rss>

