Hello all,
Hope all is well, so i need some Arcade help 🙂
- Let's say I have a point feature class which is empty and will be digitized via Field Maps.
- The map will also contain a polygon layer ,and one of its attribute is say "attribute_ABC" and has values.
- The point layer will also have attribute "attribute_ABC" which would initially be empty, so i am trying to create an attribute rule for it.
- whenever the point intersects the polygon layer, it copies the respective attribute_ABC value from the polygon layer to the point layer attribute_ABC.
- Basically the idea is to auto populate some of the attributes of the point feature class from other existing layers based on their intersection.
So I finally got the code working to the point that code block says that "Expression is valid" but when I try to add a point to the map, I get the following error
Error:
Failed to create Pt.
Failed to evaluate Arcade expression. [
Rule name: Poly,
Triggering event: Insert,
Class name: Pt,
GlobalID: {4E52CA0C-099D-4593-80AF-292A5CFE51CF},
Arcade error: Indexable type expected,
Script line: 11]
Code:
// Read the polygon layer
var poly = FeatureSetByName($datastore, "poly");
// Intersect
var int = Intersects(poly, $feature);
// Check if there is an intersection
if (Count(int) > 0) {
// Get the first intersecting polygon's ABC value
var firstPoly = First(int);
return int.ABC;
} else {
// if there's no intersection then retain the original ABC value or return null
return $feature.ABC;
}
PS the map is being created in Pro 3.3.1 which will then published to AGOL and then that map will be used in Field Maps.