Using Attribute Rules With Joined Tables To Pass Attribute Based On Intersecting Feature

188
2
Jump to solution
12-11-2020 09:47 AM
SterlingLoetz
New Contributor III

I have a question about using Attribute Rules (AR) to trigger an attribute calculation based on an intersecting polygon feature that has a joined table within ArcGIS Pro. Is there a way to use AR with joined tables? I know this can work with related records, however my question pertains specifically to joined tables in Pro. I must preface this post by saying I am very much a beginner with Arcade & AR. 

Success Thus Far: I am working with a point layer and a parcel layer. When a point feature is created inside a polygon parcel, the parcel number is passed from the parcel polygon layer to a parcel number field in the point feature class. This works great and below is my successful Arcade expression for the AR.

Working Expression.PNG

 

Current Challenge: I have a standalone table residing in the same geodatabase that house the point and parcel feature classes. The table is called "parcelview_copy". This table contains additional information about parcels and I have joined this table to the parcel polygon feature class within Pro. I want to pass a different PIN field, "ADCO_PIN" to the point feature class when a point is created within a parcel. I get this error in the Arcade expression below.

Error Expression.PNG

I'm not really sure what I'm doing wrong or if joined tables are supported by AR?

0 Kudos
1 Solution

Accepted Solutions
CooperLogan_esri
New Contributor

Hi @SterlingLoetz 

It won't be possible to access joined fields using attribute rules.  Joins exist only in the "current session" - this one particular Pro project - whereas attribute rules are stored in the geodatabase so that they can be executed from anywhere the data is accessed.

That being said, I can think of two ways to make this work.  First, you could instead build a Relationship Class in the database.  Then, you could use FeatureSetByRelationshipName to get the related features and query their attributes.

Another solution would be to build some logic using the key fields that allowed you to create the join.  In the code sample below I called these fields PrimaryKey (polygon) and ForiegnKey (table).

var ParcelLayer = FeatureSetByName($datastore, "ParcelLayer", ["PrimaryKey"]);
var Intr = Intersects(ParcelLayer, Geometry($feature));
var cnt = Count(Intr)
if (cnt == 0) {
  return null
} else {
  // get the primary key from the intersecting polygon
  var feat = First(Intr)
  var pkey = feat.PrimaryKey
  // get the standalone table
  var tbl = FeatureSetByName($datastore, "parcelview_copy", ["ADCO_Pin", "ForeignKey"]);
  // iterate through the table to find the record with a matching key value;
  // return the pin from the matching record
  for (var t in tbl){
    if (t.ForeignKey == pkey){
      return t.ADCO_Pin
    }
  }
}

 

View solution in original post

0 Kudos
2 Replies
CooperLogan_esri
New Contributor

Hi @SterlingLoetz 

It won't be possible to access joined fields using attribute rules.  Joins exist only in the "current session" - this one particular Pro project - whereas attribute rules are stored in the geodatabase so that they can be executed from anywhere the data is accessed.

That being said, I can think of two ways to make this work.  First, you could instead build a Relationship Class in the database.  Then, you could use FeatureSetByRelationshipName to get the related features and query their attributes.

Another solution would be to build some logic using the key fields that allowed you to create the join.  In the code sample below I called these fields PrimaryKey (polygon) and ForiegnKey (table).

var ParcelLayer = FeatureSetByName($datastore, "ParcelLayer", ["PrimaryKey"]);
var Intr = Intersects(ParcelLayer, Geometry($feature));
var cnt = Count(Intr)
if (cnt == 0) {
  return null
} else {
  // get the primary key from the intersecting polygon
  var feat = First(Intr)
  var pkey = feat.PrimaryKey
  // get the standalone table
  var tbl = FeatureSetByName($datastore, "parcelview_copy", ["ADCO_Pin", "ForeignKey"]);
  // iterate through the table to find the record with a matching key value;
  // return the pin from the matching record
  for (var t in tbl){
    if (t.ForeignKey == pkey){
      return t.ADCO_Pin
    }
  }
}

 

View solution in original post

0 Kudos
SterlingLoetz
New Contributor III

Hi @CooperLogan_esri this solution works great, thank you for your response and help. I have another question that I was wondering if you may some insight into. Using the above expression works for creating new points that obtain attribute information from the polygon join table. However the problem I am seeing is when I create a point in a polygon that has an existing PIN that matches a record in the joined table, there is a problem if the associated ADCO_PIN is Null. The problem occurs when updating the location of the point to a different parcel polygon.

For example, when I create a point within a polygon that has a joined table ADCO_PIN value of 012345 the ADCO_PIN will carry over to the point attribute just fine. However if I move this point to a parcel that has a joined table record, but the value is null, the ADCO_PIN in the point feature class will not update to null as seen in new parcel. It will still show the PIN 012345 of the previous parcel polygon. I worked with the expression a little but could not find a solution. Thanks for any insight.

Tags (1)
0 Kudos