Hello!
I am trying to write an attribute rule that will populate fields in a feature class from a standalone table as I am creating new features. I don't want to use a join.
I'm not sure I'm even starting in the right place with this script, but what I would like to have happen is that if I create a point in the bedrock_MUL line feature class and manually enter the MapUnit it would populate the UnitCode field in the feature class using the Bedrock_DMU table below.
I have this attribute rule written for the UnitCode field in the Bedrock_MUL feature class.
// When adding a new MapUnitLabel to the map first pick you MapUnit from the bedrock DMU and enter it in the MapUnitField, that entry will trigger the population of the UnitCode field here
//$datastore is the entire workspace
// $feature is the point being added
// Reference Fields in the DMU
var fsBedrock_DMU_MapUnit = FeatureSetByName($datastore, "Bedrock_DMU", ["MapUnit"]);
var fsBedrock_DMU_UnitCode = FeatureSetByName($datastore, "Bedrock_DMU", ["UnitCode"]);
var fsBedrock_MUL_MapUnit = $feature["MapUnit"];
//Look at Feature class and if it matches table return value from table
if ($feature.MapUnit == fsBedrock_DMU_MapUnit.MapUnit)return fsBedrock_DMU_UnitCode.UnitCode
The error tends to point me towards the missing curly brackets. Does this change things?
if ($feature.MapUnit == fsBedrock_DMU_MapUnit.MapUnit){
return fsBedrock_DMU_UnitCode.UnitCode
}
R_