I'm trying to apply an attribute rule to an enterprise geodatabase feature class.
I have a tree feature class that has both species (scientific) and common name attribute. I'm trying to automatically fill in the common name based on what species an editor enters. I have a lookup table, ENV_TREESPECIES_LUT, that lists the species name and common name.
The general workflow I'm trying to achive is:
If a new tree feature has a species value then search the ENV_TREESPECIES_LUT for that species and return the common name
But no no matter what logic I've tried the attribute rule editor in Pro gives me an evaluation error on line 5 of this script below. It seems to the filter function. What is the correct way to filter on an feature attribute?
I should mention that the code validates in the expression builder, the error is only thrown when I try to save the attribute rule.
var cn = ""
var fspecies = $feature.Species
if(! isEmpty($feature.Species))
var LUT = FeatureSetByName( $datastore, "ENV_TREESPECIES_LUT", ["Species", "CommonName"], false)
var common_names = Filter(LUT, "Species = @fspecies")
var common_name = first(common_names)
if (! IsEmpty(common_name.CommonName))
cn = common_name.CommonName
return cn
Solved! Go to Solution.
Your if statements need curly braces, not just indents. I think that's all you'd need to adjust there.
if(condition){
// do something
if(another_condition){
// do another thing
}
}
Your if statements need curly braces, not just indents. I think that's all you'd need to adjust there.
if(condition){
// do something
if(another_condition){
// do another thing
}
}
It works perfectly now.
thank you.