Calculate field based on common geometry using Attribute Rules

1096
3
08-28-2019 10:49 AM
Brian_McLeer
Occasional Contributor II

Being new to Arcade and Attribute rules, I am trying to put in place a rule that populates a tax lot ID number on an address point upon insert or update. The error I receive comes from line 6 at the bottom of the thread.

             ERROR 002717: Invalid Arcade expression, Arcade error: Table not found WC Tax Lots

What I am having trouble connecting the dots is how to grab the TLNO from the tax lot polygon and assign it to the TLNO GIS field in the address point feature class. In my Contents, the tax lot layer is titled as WC Tax Lots as it is in the code below.

I received the code sample from GitHub - Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in t... 

// Value to copy from the intersected feature
var intersecting_field = "TLNO GIS";
//Field rule is assigned to in the Attribute Rule
var feature_field = "TLNO";
// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, "WC Tax Lots", [intersecting_field], true);
// Intersect the edited feature with the feature set and retrieve the first feature
var intersected_feature = First(Intersects(intersecting_featset, $feature));
// Check to make sure there was an intersected feature, if not, return the original value
if (intersected_feature == null)
{
 return $feature[feature_field];
}
// If the intersected feature is null, return the original value
if (IsEmpty(intersected_feature.valueToCopy))
{
 return $feature[feature_field];
}
// Return the intersected features value
return intersected_feature[intersecting_field];
Brian
0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

Hi brianmcleer ,

If you use the $datastore to access a featureset, you will have to use the exact name if the featureclass in the datastore. It does not matter how you call something in the TOC. 

Also remember to change the "valueToCopy" on line 15 to the actual field name.

Brian_McLeer
Occasional Contributor II

Thanks, Xander,

For the exact feature class name, is that the entire connection string, or feature class name itself? Also, the tax lot feature class resides in a separate database than the address points. 

Brian
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Brian McLeer , 

It will probably be a problem is the data does not reside in the same datastore. It uses the datastore of the current layer/feature to search for other featureclasses by its exact name in the datastore. So it will be using the featureclass name and not the entire connection string.