Select to view content in your preferred language

Attribute Rule Arcade Intersect and Copy Attribute from Feature A to B Error: Indexable type expected

138
3
Jump to solution
a week ago
Labels (2)
Ed_
by MVP Regular Contributor
MVP Regular Contributor

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.

 

 

 

 

 

 

Question | Analyze | Visualize
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Line 10 should be

return firstPoly.ABC;

View solution in original post

3 Replies
Ed_
by MVP Regular Contributor
MVP Regular Contributor

@jcarlson @KenBuja @XanderBakker can any of you you please help? 

Question | Analyze | Visualize
0 Kudos
KenBuja
MVP Esteemed Contributor

Line 10 should be

return firstPoly.ABC;
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Good morning Ken, hope all is well 🙂

Yup that did it, thank you so much and have a great day!

Question | Analyze | Visualize
0 Kudos