Select to view content in your preferred language

Attribute Rule to Intersect using Portal Item

769
2
12-06-2023 07:50 AM
Labels (2)
Jennifer_Parmeley
Frequent Contributor

I would like to create an Attribute Rule that intersects new points with a polygon that is hosted in our ENT portal. 
FeatureSetByPortalitem function seems like it would be the best function, but it's not available in the Function list in the attribute rules. I'm new to this, so I'm asking anyway. 
https://developers.arcgis.com/arcade/function-reference/portal_functions/#featuresetbyportalitem

My end goal is to publish a service that users with edit in Web App Builder. I'd like to populate as many attributes as possible automatically. Ease the burden on the program users. I currently have a domain set for county value, so there's a pick list, but it would be nice if I could calculate the county based on where the point is placed. I have an attribute rule that calculates email address, based on a domain list of people and this led me to think maybe I could do the same for county.

This made my idea look possible https://community.esri.com/t5/arcgis-pro-questions/how-to-add-values-from-polygon-to-points-which-ar... but our county layer is hosted by our enterprise team - it isn't in my database. 
https://community.esri.com/t5/arcgis-pro-questions/arcade-and-attribute-rules-featuresetbyname/td-p/...

Maybe FeatureSetById would work?
https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyid
But I cannot get it to find/load my table. I keep getting the error: Invalid expression. Table not found. 
My code for that line looks like this

var polygons = FeatureSetById($datastore, `1`, ['Name'])

When I add that layer to my map it comes in as a single item in a group. Even though I've pulled it out of the group, could this be the issue? Is it seen as a feature collection?

CountyGroup.png


I have checked the UniqueID box in the map properties, maybe I have the wrong ID?
CountyID.png

I'd appreciate any help on this one. Thanks!

0 Kudos
2 Replies
rlyding
Regular Contributor

I believe for $datastore to work the County Layer would need to be in your database and $map can't be used in a attribute rule.

Not sure what your options are for web apps. One idea would be to setup a web map with the County Layer and the layer you are editing. You could then configure a Form that can calculate fields using Arcade Expressions. At this level you could use FeatureSetByName and $map to pull in the County Layer data and Intersects() with your layer and populate the field.

You wouldn't be able to use WAB, but you could use InstantApp Side Bar Template with Editor or create a Experience Builder both of which can use the Form you configure in the web map builder. Field Maps would also work.

Robert_LeClair
Esri Notable Contributor

There's an example very similar to what you want to do using Arcade expressions in an ArcGIS Field Maps blog posting.  Since Arcade is a platform wide expression language, the Arcade code in example 1 of this blog should work in ArcGIS Pro as an calculated attribute rule.  Not sure how this would work in a web app though...

0 Kudos