Use Arcade to populate fields from other layers

268
1
07-26-2021 03:52 PM
JordanEvans2
New Contributor

Hello,

I am wondering if it is possible to do the workflow I am imagining. I would like to use Arcade Expressions and Attribute Rules to auto populate a number of fields on a layer based on what other layers they intersect.

For example, I would like to publish an address service to my Portal and when a point is added, have fields like "subdivision", "town", "precinct", etc.. all fill automatically based on where the new address point intersects those other layers. Another example would be placing a main break point on a water main, there are some attributes in the water main layer that would be nice to carry over to the break layer automatically when the break is created.

All of the documentation I have found about Attribute Rules that talks about using fields to populate other fields, only shows this occurring within the same layer. Is it possible to auto fill attributes on a service from the attribute of another service?

Thanks,

Jordan

0 Kudos
1 Reply
jcarlson
MVP Regular Contributor

If you take a look at the Attribute Rule Arcade profile, you'll see that it does have access to the global $datastore. This means that provided the layers in question are in the same geodatabase, you can use inter-layer calculations, including spatial operations.

// Grabbing an attribute from intersected layer

// Get other layer from datastore 
var other_layer = FeatureSetByName($datastore, "other_layer_name")

// Intersect layer and feature, use `First` to take the top feature
var xs_feat = First(Intersects($feature, other_layer))

return xs_feat["some_attribute"]

If, however, the other layer is outside of the database, you'll have to use a field calculation in order to access it. But you could create a script which runs the calculation at often enough intervals to keep things up to date.

- Josh Carlson
Kendall County GIS
0 Kudos