EDIT: I've isolated the problem to the Push function to supply the dictionary with the value. I can't see what I'm doing wrong here. Again, this works just fine in Map Viewer but not in Field Maps.
// Iterate through the filtered RCS, grab the Structure ID, convert it to a number, and then push it to the new Feature Set
for(var R in RCS_in_District){
var RCS_ID_txt = R['StructureID']
var RCS_ID_num = Number(RCS_ID_txt)
Push(
RCS_d["features"],
{
attributes: {
RCS_ID: RCS_ID_num,
},
},
)
}
This works just fine and dandy in Map Viewer but "fails to calculate" in Field Maps. Note that I am testing Field Maps online - I don't need a disconnected environment.
Goal: Use Arcade expression to autopopulate StructureID field in Road Class Structures with a unique sequential ID based upon the District it falls in.
Assumptions/Logic:
- Road Class Structures is a line layer that the user draws
- Contains field called "StructureID" (text). "StructureID" has the following naming convention:
- <District #> +
-digit sequential number> (i.e. the 347th Road Class Structure in District 3 gets a StructureID = 3347)
- Tulsa County District Boundaries is a polygon layer of District Boundaries (3 total)
- Contains field called "District" (text). Values are "1", "2", or "3"
Process:
- If User edits an existing Road Class Structure, the ID does not change.
- If User draws a new Road Class Structure
- Intersects the $feature against the District to get the District ID
- if it falls outside a District, it gets a value of "9999"
- If it falls inside a District:
- Filters all Road Class Structures whose Structure ID starts with the District #
- Creates a dictionary to store all the Structure IDs
- Iterates over the filtered Road Class Structures and populates the dictionary with the numerical equivalent of the Structure ID
- Returns a FeatureSet of the dictionary
- Sorts it by Structure ID descending
- Grabs the first value (which is the highest number)
- Highest number + 1
- Converts that to text and returns it
-