Select to view content in your preferred language

Feature Set By Name & Multiple Layers in Map

478
0
12-17-2021 08:05 AM
AnneSantaMaria
New Contributor III

We are working in an enterprise stand alone portal environment. Publishing from ArcGIS Pro 2.9 and the latest version of ArcGIS enterprise with branch versioned data. 

I have an attribute rule that calculates the upstream and downstream manhole ID of a pipe segment when the pipe is inserted or updated.  

var linegeometry = Geometry($feature);
var toPointGeometry = linegeometry.paths[-1][-1];
var fsManhole = FeatureSetByName($datastore, "Enterprise database. DManholes", ["FACILITYID"], false);
var fsCB = FeatureSetByName($datastore, "Enterprise database.DCatchbasin", ["FACILITYID"], false);
var toManhole = First(Intersects(fsManhole, toPointGeometry));
var toCB = First(Intersects(fsCB, toPointGeometry ));
if ((toManhole == null) && (toCB != null))
return {
"result": {
"attributes": {
"DSNODEID": toCB.FACILITYID,
}
}
}
if ((toManhole != null) && (toCB == null))
return {
"result": {
"attributes": {
"DSNODEID": toManhole.FACILITYID,
}
}
}

This script works perfectly on a service in which there is one manhole, one catchbasin, and one storm layer published to portal, so lets say 3 layers, each of them unique and not pointing to the same feature class. This is not totally realistic as we also show abandoned mains, manholes, and catchbasins using definition queries in the map and then publish this as service to portal. So now we have 6 layers 2 of each feature class, abandoned manholes and not abandoned manholes etc.

When I try to create a new main between my points the attribute rule doesn't populate the expected fields. When I review the attribute rule on the mains I have noticed that it is pointing to the incorrect layer ID. The script for the published attribute rule is shown below.

var linegeometry = Geometry($feature);
var toPointGeometry = linegeometry.paths[-1][-1];
var fsManhole = FeatureSetByName($datastore, "L5Manholes_Abandoned", ["FACILITYID"], false);
var fsCB = FeatureSetByName($datastore, "L4Catchbasins_Abandoned", ["FACILITYID"], false);
var toManhole = First(Intersects(fsManhole, toPointGeometry));
var toCB = First(Intersects(fsCB, toPointGeometry ));
if ((toManhole == null) && (toCB != null))
return {
"result": {
"attributes": {
"DSNODEID": toCB.FACILITYID,
}
}
}

if ((toManhole != null) && (toCB == null))
return {
"result": {
"attributes": {
"DSNODEID": toManhole.FACILITYID,
}
}
}

My question is am I using the wrong function to call the feature classes I am using for the intersection?

It seems like a giant pain to publish a map with the bare minimum of layers then go through each layer and symbolize, apply a definition query etc and share it with others across an organization.  Then lets say something changes/goes wrong and the connection breaks and someone (a user who only views or interacts with GIS once a year) brings the service back into their pro project and has to do that same step over and over again. 

@HusseinNasser2 

Learn how attribute rules can be used to automate attribution and copy attributes from one feature class to another. Download the sample project and data used in this video: http://ow.ly/W3Ea50B5Mnj For more information, please visit: http://ow.ly/4lrT50ANueJ ...
0 Kudos
0 Replies