Hi Everyone,
I'm trying to edit a line feature class when a To Node point is moved. The arcade attribute rule I wrote works, but it only moves 1 line that has a matching ID. It seems like it is the first OBJECTID the script encounters. For some reason, the rest of the lines aren't moving. Does anyone see anything in this code that could be preventing that?
var pointGeometryX = Text(Geometry($feature).x) //X Coordinate of Point to Be Moved
var pointGeometryY = Text(Geometry($feature).y) //Y Coordinate of Point to Be Moved
var pointID = $feature.assetID //Asset ID of Point to be Moved
var lineImport = FeatureSetbyName($datastore, "LineLayer",['*'],true) //Line Layer to be moved based on new location of Point
var lineFilter = filter(lineImport "assetNodeTo = @pointID") //Filter Line Layer to just the To Nodes that join to the moved point, Join is based on Asset ID (point.assetID=line.assetNodeTo)
var AddList = [] //Create empty list
var counter = 0 //Set counter
var numToNodes= Count(lineFilter) //Get Count of Filtered data
if (numToNodes > 0) { //If there are 1 or more To Nodes, execute loop
for (var i in lineFilter) { //Loop through all rows in filtered data
var LineGeomPaths = Geometry(i).paths ;//Get Geometry of Line Layer
var fromNodeGeom = LineGeomPaths[0][0]; //Get From Nodes XY Coordinates
var fromNodeGeomX = Text(fromNodeGeom.x); //Get Text From Node X
var fromNodeGeomY = Text(fromNodeGeom.y); // Get Text From Node Y
var polylineJSON = { "paths": [[[fromNodeGeomX,fromNodeGeomY,0],[pointGeometryX,pointGeometryY,0]]],"spatialReference": {"wkid":2249}}; //Build Polyline layer with new To Node (New moved point geometry), keep same From Node
var polyFinal=Polyline(polylineJSON)// Build Polyline
AddList[counter] = {'OBJECTID': i.OBJECTID,'geometry': polyFinal}; //Add to List
}
}
counter++
}
return {'result': i.OBJECTID,'edit': [{'className': 'LineLayer','updates': AddList}]}//Return edit statement
else { return $feature.assetID} //If no To Nodes, overwrite the assetID with current value and exit loop