<?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: ERROR 002717: Invalid Arcade expression, Arcade error: Identifier expected, Script line: -1548759840 in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/error-002717-invalid-arcade-expression-arcade/m-p/1222678#M608</link>
    <description>&lt;P&gt;Many thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That worked very well and I'm now able to successfully add that attribute rule using this ArcPy code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.AddAttributeRule(lrsNetworkFC,"Update x_end","CALCULATION",
                                  r"return Geometry($feature).paths[-1][-1].x;",
                                  "EDITABLE", "INSERT;UPDATE", '', '', '', '', "x_end",
                                  "INCLUDE", "NOT_BATCH", None, None)&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 18 Oct 2022 00:24:22 GMT</pubDate>
    <dc:creator>GraemeBrowning_Aurizon</dc:creator>
    <dc:date>2022-10-18T00:24:22Z</dc:date>
    <item>
      <title>ERROR 002717: Invalid Arcade expression, Arcade error: Identifier expected, Script line: -1548759840</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-002717-invalid-arcade-expression-arcade/m-p/1222397#M602</link>
      <description>&lt;P&gt;I'm trying to set an Attribute Rule using ArcPy, ArcGIS Pro 3.0.2, a file geodatabase and this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    arcpy.management.AddAttributeRule(lrsNetworkFC,"Update x_end","CALCULATION",
                                      r"var line_geo =  Dictionary(Text(Geometry($feature)));"\
                                      "var paths = line_geo['paths'];"\
                                      "var vertex_count = 0;"\
                                      "for (var path_idx in paths){;"\
                                      "    for (var vert_idx in paths[path_idx]){;"\
                                      "        vertex_count++;"\
                                      "    };"\
                                      "};"\
                                      "return paths[0][vertex_count - 1][1];",
                                      "EDITABLE", "INSERT;UPDATE", '', '', '', '', "x_end",
                                      "INCLUDE", "NOT_BATCH", None, None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I'm getting an ERROR 002717:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;Traceback (most recent call last):
  File "\\bneprdfps24\gis\GIS\PROJECTS\GRAEME\Scripts\CreateAndLoadLRSDatasetFromCQCN.py", line 391, in &amp;lt;module&amp;gt;
    arcpy.management.AddAttributeRule(lrsNetworkFC,"Update x_end","CALCULATION",
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 1183, in AddAttributeRule
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 1180, in AddAttributeRule
    retval = convertArcObjectToPythonObject(gp.AddAttributeRule_management(*gp_fixargs((in_table, name, type, script_expression, is_editable, triggering_events, error_number, error_message, description, subtype, field, exclude_from_client_evaluation, batch, severity, tags), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in &amp;lt;lambda&amp;gt;
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: &lt;/SPAN&gt;ERROR 002717:&lt;SPAN class=""&gt; Invalid Arcade expression, Arcade error: Identifier expected, Script line: -1548759840
Failed to execute (AddAttributeRule).&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Is there something obvious that is wrong with my syntax?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use the Attribute Rule to write the X coordinate of the last vertex along a polyline (which is a route in a Roads and Highways LRS Dataset) to a field in its attribute table&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 06:51:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-002717-invalid-arcade-expression-arcade/m-p/1222397#M602</guid>
      <dc:creator>GraemeBrowning_Aurizon</dc:creator>
      <dc:date>2022-10-17T06:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 002717: Invalid Arcade expression, Arcade error: Identifier expected, Script line: -1548759840</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-002717-invalid-arcade-expression-arcade/m-p/1222401#M603</link>
      <description>&lt;P&gt;There are no syntax errors, so this error message is somewhat perplexing.&lt;/P&gt;&lt;P&gt;There are however other problems with your expression:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You say you want to return the x coordinate, but you actually return the y coordinate. x is index 0.&lt;/LI&gt;&lt;LI&gt;You calculate the vertex count of the whole multipart geometry and then return that index from the first part. That works for singlepart features, but it will give an error for multipart features, as vertex_count will be greater that the length of the first part.&lt;/LI&gt;&lt;LI&gt;You can do it with a single line:&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="javascript"&gt;// no need to convert to Dictionary, you can just call paths
// index -1 gets the last element of an array. paths[-1][-1] gets the last point of the last part.
return Geometry($feature).paths[-1][-1].x&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this expression. If the error still occurs, try setting the rule manually.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 07:51:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-002717-invalid-arcade-expression-arcade/m-p/1222401#M603</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-10-17T07:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 002717: Invalid Arcade expression, Arcade error: Identifier expected, Script line: -1548759840</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-002717-invalid-arcade-expression-arcade/m-p/1222678#M608</link>
      <description>&lt;P&gt;Many thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That worked very well and I'm now able to successfully add that attribute rule using this ArcPy code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.AddAttributeRule(lrsNetworkFC,"Update x_end","CALCULATION",
                                  r"return Geometry($feature).paths[-1][-1].x;",
                                  "EDITABLE", "INSERT;UPDATE", '', '', '', '', "x_end",
                                  "INCLUDE", "NOT_BATCH", None, None)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 18 Oct 2022 00:24:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-002717-invalid-arcade-expression-arcade/m-p/1222678#M608</guid>
      <dc:creator>GraemeBrowning_Aurizon</dc:creator>
      <dc:date>2022-10-18T00:24:22Z</dc:date>
    </item>
  </channel>
</rss>

