I'm trying to set an Attribute Rule using ArcPy, ArcGIS Pro 3.0.2, a file geodatabase and this code:
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)
but I'm getting an ERROR 002717:
Traceback (most recent call last):
File "\\bneprdfps24\gis\GIS\PROJECTS\GRAEME\Scripts\CreateAndLoadLRSDatasetFromCQCN.py", line 391, in <module>
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 <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 002717: Invalid Arcade expression, Arcade error: Identifier expected, Script line: -1548759840
Failed to execute (AddAttributeRule).Is there something obvious that is wrong with my syntax?
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