Good Morning!
After an Enterprise update we switched from using ArcGIS Attribute assistant to the new arcGIS pro Attribute Rules. I'm trying to adapt rules that we already had in attribute assistant into attribute rules. Admittedly, I'm working on strengthening my arcade but I feel like this should be easy so I'm not sure what I'm doing wrong and wanted to see if any of you fine people could help.
I'm working with a parcel fabric, but what I am trying to do is to do an intersect between a parcel that is new or edited, intersect that with a zip code layer that lies within the same map as the parcels, and return the zip code to the parcel. i have looked through a lot of the Esri documentation and have come up with the code below. but get an error when I try to implement it.
Current code i have in arcade is:
var geom2 = Polygon({ZipCodes});
first( Intersects($layer, geom2) );
Return Zipcodes.ZIPCODE
Am I missing something? it seems to be what i would think is easy but have had no luck yet. Thanks in advance with the help!
There are a few issues in the expression you've shared.
var portal = Portal('your-url')
var zips = FeatureSetByPortalItem(
portal,
'item-id-of-zips-layer',
0, // Or whatever layer index your zips are in
['ZIPCODE'],
true
)
var first_zip = First(Intersects($feature, zips))
return first_zip['ZIPCODE']
Also worth considering: if your parcels and zips don't align perfectly, there may be situations in which a tiny sliver of a zip code is caught by the intersection, and it mistakenly gets returned by first. If it's an issue, you can try something like taking the centroid of the feature before intersecting it with your zip codes.