Hello,
I am using Attribute Rules and want to automate assigning numbers to newly created layers within a polygon. Eg. If I create a point in quad 267N, I want to look for the last number used for that point feature within that quad, and assign it the next sequential number. The script that I am working on returned an error when verifying, "Invalid expression. Error on line 9. String type expected"
// Layers
var valves = FeatureSetByName($datastore, "dwSystemValve");
var quad = FeatureSetByName($datastore, "AtlasGrid_AtlasBook");
// Get the geometry of the current valve
var valveGeometry = Geometry($feature);
// Find the quad that contains the current valve
var containingQuad = First(Intersects(quad, $feature));
// If no quad is found, return an error or default value
if (IsEmpty(containingQuad)) {
return "No quad found";
}
// Get the quad sheet number of the current quad
var sheetID = containingQuad.SHEET;
// Query valves within the same quad
var valvesInQuad = Filter(valves, "SHEET = @sheetID");
// If no valves exist in the quad, start from 1
if (IsEmpty(valvesInQuad)) {
return 1;
}
// Find the highest valve number in the quad
var maxValve = Max(valvesInQuad, "NUM");
// Return the next available number
return maxValve +1;