<?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: How can I CalculateField_Management a field that has a Domain based schema? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45683#M3634</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your error dump&amp;nbsp;messages do not match your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect you need a&amp;nbsp;prefix and "." to access the GlobalID field in the related table, especially when there are unusual paths to access the data sources.&amp;nbsp; Although a usually helpful way to find the syntax is to use Describe to&amp;nbsp;use the name property to get the prefix. Note my use of Python&amp;nbsp;.format() -- much easier when the syntax gets weird to keep things straight!&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;tbl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{}__ATTACH_vw"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;combinedOutFC&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
expr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"!{}.GlobalID!"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this doesn't always work, specially when working with&amp;nbsp;SDE joins, raster tables, etc. In these cases sometimes I need to resort to printing a debug message with the field names so I can see what syntax Python is looking for to access the joined field:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;)&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 21:46:52 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-10T21:46:52Z</dc:date>
    <item>
      <title>How can I CalculateField_Management a field that has a Domain based schema?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45682#M3633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm having a DOH! moment here am can't seem to pull myself out of the nosedive.&amp;nbsp; Converting my scripts&amp;nbsp;using&amp;nbsp;arcpy.CalculateField_management from VB to Python and ran into a small hiccup.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using VB, this is what I did:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;arcpy.CalculateField_management(combinedOutFC + '__ATTACH_vw', 'REL_GLOBALID', '[DBName."Domain\!UserSchema".FC_Publish.GlobalID]')&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But in Python, that is not cool so I did this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;arcpy.CalculateField_management(combinedOutFC + '__ATTACH_vw', 'REL_GLOBALID', '!GlobalID!', 'PYTHON_9.3'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here&amp;nbsp;is the caveat:&lt;/P&gt;&lt;P&gt;Prior to this I performed a join:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;arcpy.AddJoin_management(combinedOutFC + "__ATTACH_vw", "REL_GLOBALID", combinedOutFC, "GUIDCopy")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Where I am going wrong with:&lt;/STRONG&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;arcpy.CalculateField_management(combinedOutFC + '__ATTACH_vw', 'REL_GLOBALID', '!GlobalID!', 'PYTHON_9.3'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks ahead of time for what I know will be "oh yeah" moment of the day for me.&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp; Thank you all for your help over the years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh!!!&amp;nbsp; Error is looking like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;error encountered.ERROR 000539: Invalid field &lt;SPAN style="background-color: #f6f6f6;"&gt;FeatureClass&lt;/SPAN&gt;.GlobalID&lt;BR /&gt;Failed to execute (CalculateField).&lt;BR /&gt;PYTHON ERRORS:&lt;BR /&gt;Traceback info:&lt;BR /&gt; File "Publish.py", line 182, in &amp;lt;module&amp;gt;&lt;BR /&gt; arcpy.CalculateField_management(combinedOutFC + '__ATTACH_vw', 'REL_GLOBALID', '!' + combinedOutFC + '.GlobalID!', 'PYTHON_9.3')&lt;/P&gt;&lt;P&gt;Error Info:&lt;BR /&gt;ERROR 000539: Invalid field FeatureClass.GlobalID&lt;BR /&gt;Failed to execute (CalculateField).&lt;BR /&gt;Closing Log File and Exiting Process.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2019 23:06:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45682#M3633</guid>
      <dc:creator>John_Spence</dc:creator>
      <dc:date>2019-04-02T23:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I CalculateField_Management a field that has a Domain based schema?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45683#M3634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your error dump&amp;nbsp;messages do not match your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect you need a&amp;nbsp;prefix and "." to access the GlobalID field in the related table, especially when there are unusual paths to access the data sources.&amp;nbsp; Although a usually helpful way to find the syntax is to use Describe to&amp;nbsp;use the name property to get the prefix. Note my use of Python&amp;nbsp;.format() -- much easier when the syntax gets weird to keep things straight!&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;tbl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{}__ATTACH_vw"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;combinedOutFC&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
expr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"!{}.GlobalID!"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this doesn't always work, specially when working with&amp;nbsp;SDE joins, raster tables, etc. In these cases sometimes I need to resort to printing a debug message with the field names so I can see what syntax Python is looking for to access the joined field:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;)&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:46:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45683#M3634</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-10T21:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I CalculateField_Management a field that has a Domain based schema?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45684#M3635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh my, that was an approach I had not considered.&amp;nbsp; Definitely going to give that a shot this morning and will drop you a line with the outcome.&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2019 13:38:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45684#M3635</guid>
      <dc:creator>John_Spence</dc:creator>
      <dc:date>2019-04-03T13:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I CalculateField_Management a field that has a Domain based schema? </title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45685#M3636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So...after further investigation it turns out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The field is a GlobalID (not modifiable/calculable via this method).&amp;nbsp; It need to be a GUID to be changeable this way if memory serves.&lt;/LI&gt;&lt;LI&gt;I'm hanging my head in shame standing in the corner.&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your insight as it was incredibly helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2019 14:49:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-calculatefield-management-a-field-that/m-p/45685#M3636</guid>
      <dc:creator>John_Spence</dc:creator>
      <dc:date>2019-04-03T14:49:50Z</dc:date>
    </item>
  </channel>
</rss>

