<?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: Attribute rule error on python updatecursor in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1232968#M663</link>
    <description>&lt;P&gt;Is there a means of programmatically (ArcPy) getting a list of all fields that are involved in Attribute Rule Calculations? It appears that it is possible to use arcpy.da.Describe with the ['attributeRules'] key to obtain the names of the fields that have calculations &lt;STRONG&gt;applied&lt;/STRONG&gt;, but that will not include fields that might be&amp;nbsp;&lt;STRONG&gt;part of the calculation&lt;/STRONG&gt;. For example, you can get the name of Field3 where the calculation is applied, but I don't see a means of getting the names of Field1 and Field2 that are used to calculate a sum, for example, to be populated in Field3.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 21:39:39 GMT</pubDate>
    <dc:creator>VinceE</dc:creator>
    <dc:date>2022-11-17T21:39:39Z</dc:date>
    <item>
      <title>Attribute rule error on python updatecursor</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1125604#M277</link>
      <description>&lt;P&gt;In ArcGIS Pro 2.8.3 when trying to update a feature using Python update cursor an error occurs (see below).&amp;nbsp; This error occurs in our enterprise implementation of the Water Utility Network Solution and also when using the &lt;STRONG&gt;sample Naperville data provided in a file geodatabase&lt;/STRONG&gt;.&amp;nbsp; Editing workflows in the ArcGIS Pro UI work fine for this type of edit.&amp;nbsp; These attribute rules were provided as part of the Water Utility Network Solution. If I disable the attribute rule it will fail on another rule (Water Line - MeasuredLength From Shape), when both are disabled the edit occurs without error.&amp;nbsp; Here is a simplified snippet of code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
idFeature = []

for lyr in m.listLayers():
    lyrdesc = arcpy.Describe(lyr)
    if lyr.isFeatureLayer:
        fi = lyrdesc.fieldInfo
        obj = lyrdesc.FIDSet
        if obj:              
            wc =  "OBJECTID in ({0})".format(obj.replace(";",","))
            print(wc)
            with arcpy.da.UpdateCursor(lyr, ["OID@", "NOTES"],wc) as cursor:
                for row in cursor:
                    row[1] = "TEST"
                    cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RuntimeError: Failed to evaluate Arcade expression. [&lt;BR /&gt;Rule name: Water Line - Cathodic Protection Traceability,&lt;BR /&gt;Triggering event: Update,&lt;BR /&gt;Class name: WaterLine,&lt;BR /&gt;GlobalID: ,&lt;BR /&gt;Arcade error: Field not found cptraceability,&lt;BR /&gt;Script line: 25]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 21:47:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1125604#M277</guid>
      <dc:creator>JimmyBowden</dc:creator>
      <dc:date>2021-12-13T21:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule error on python updatecursor</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1125625#M278</link>
      <description>&lt;P&gt;This is happening because the AR tried to use a field that was not fetched by python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Two solutions,&lt;/P&gt;&lt;P&gt;you can wrap the python call&amp;nbsp;&lt;SPAN&gt;with arcpy.da.Editor(str(workspacepath)) which will give the editor context.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or you can include all the fields that the AR require in the UpdateCursor call (cptraceability) in this case.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 22:51:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1125625#M278</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2021-12-13T22:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule error on python updatecursor</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1125630#M279</link>
      <description>&lt;P&gt;Or turn the rule off when you are running the update cursor....&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 23:20:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1125630#M279</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-13T23:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule error on python updatecursor</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1232968#M663</link>
      <description>&lt;P&gt;Is there a means of programmatically (ArcPy) getting a list of all fields that are involved in Attribute Rule Calculations? It appears that it is possible to use arcpy.da.Describe with the ['attributeRules'] key to obtain the names of the fields that have calculations &lt;STRONG&gt;applied&lt;/STRONG&gt;, but that will not include fields that might be&amp;nbsp;&lt;STRONG&gt;part of the calculation&lt;/STRONG&gt;. For example, you can get the name of Field3 where the calculation is applied, but I don't see a means of getting the names of Field1 and Field2 that are used to calculate a sum, for example, to be populated in Field3.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 21:39:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1232968#M663</guid>
      <dc:creator>VinceE</dc:creator>
      <dc:date>2022-11-17T21:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule error on python updatecursor</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1260008#M731</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/346994"&gt;@HusseinNasser2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in my case I am doing same edit against a feature service&lt;/P&gt;&lt;P&gt;it seems as if from arcpy it is indicated to do edits against database, and not against services&lt;/P&gt;&lt;P&gt;to make edits against a feature service I should use arcpy or arcgis for python. How could I get the same result using ArcGIS API for Python?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 10:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-error-on-python-updatecursor/m-p/1260008#M731</guid>
      <dc:creator>geopamplona</dc:creator>
      <dc:date>2023-02-21T10:59:37Z</dc:date>
    </item>
  </channel>
</rss>

