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
Solved! Go to Solution.
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.
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.
Hi Josh!
What if I wanted to just pull the record from an intersect with line to point (same fgdb)? Ex., fields: diameter to diameter. Now these are in a domain, not sure if this matters, the syntax examples and descriptions on Esri Arcade pages are very vague and ambiguous. I rarely code. Does 'First' function mean it pulls the current attribute? And is it pulling the code or the description? I so miss Attribute Assistant! Help is greatly appreciated!!! I use AGO and append data because we are a small city and I don't need ArcGIS server. AR's can't be used with edits to AGO data in ArcPro, which really is a disadvantage for me. AA was much easier to use and worked perfectly. Now it seems as though you need to write 20 lines of code to do a simple edit.
Hi @jcarlson
This is the closest thing to what I need to do and I am hoping you can help me out here. Is it possible to do a double intersect? My organization is moving to Utility Network and we need to recreate all the Attribute Assistant methods into Attribute Rules. The specific one we are stuck on is copying hydrant numbers from valve number. There is no relationship between them except that they are snapped to the same fire lateral line. All layers reside in the same SDE database. Hope you can help.
Thank you for being a contributor.
@jcarlson can you tell me why the below works for one polyline layer in my map:
// Get other layers from map
var portal = Portal("https://gxxxxe.xxxx.org/portal")
var PZ = FeatureSetByPortalItem (portal,"5xxxxxxxa",1, ['controlhgl'],true);
// PZ intersect with the main you clicked on
var hgl = First(Intersects(PZ, $feature))
return hgl.controlhgl
But the identical code will not work for another polyline layer within the same map giving the below error:
Execution Error:Runtime Error: Cannot call member method on null. controlhgl
For some reason the second polyline appears to never intersect with the same polygon as the first polyline, despite that clearly not being the case.
You get a null when there are no intersecting features. Double check the layers' CRS, maybe? Or check to see that the features are actually intersecting. Is the "main" in your code a point? A point-line intersection is a single point, and even a minute offset will cause the intersection to fail. You could try buffering the input feature a small amount to catch such situations.
@jcarlson it's a polyline to polygon intersection. And I double checked to ensure both lines are inside of the same polygon - they are. For the Polyline that works I see that my intersect returns a featureset, and then a feature within that:
For the polyline that fails to register as intersecting with the polygon I get no such featureset, and therefore no feature to grab my attributes from:
This polyline has the same spatial ref as the first, but does have significantly more complex geometry. But, once again, the two polyline featureclasses do definitely intersect the polygon featureclass spatially: