Select to view content in your preferred language

Vlookup attribute rule between feature class and standalone table

337
1
12-08-2022 09:16 AM
katherinealexander_123
New Contributor

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 

Screenshot 2022-12-08 101328.png

0 Kudos
1 Reply
RhettZufelt
MVP Notable Contributor

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_

0 Kudos