$Feature.Field returns as empty when used as a parameter or in any context other than just itself.

596
3
04-17-2022 06:15 AM
Glasnoct
New Contributor III

I'm trying to get the object in my attribute pane to display based on a related feature's values so I can more easily identify some things about my selected object but I'm getting puzzling behavior from the $Feature.Field variable. We didn't have this issue in Arcpy before we realized that display properties expressions only allow Arcade, which we're even less familiar with and so we're having no luck. The selected nonspatial object exists in a standalone table (where we're trying to modify the display) and the feature we're trying to access is a spatial object in a layer if that matters.

Here are the different attempts at trying to figure out what syntax will actually return the variable not-empty.

//This alone verifies and displays correctly for labeling purposes
$Feature.Origin_ID

//All of the following return empty but still verify
var OID = $Feature.Origin_ID
return OID

or

Console(OID)

or

Console(Text($Feature.Origin_ID)) //thought it might be a format issue

 

forcing the console to return something along with the variable or using it in an sql expression reveals it's returning empty

//returns ORIGINID='' in console
var sql = "ORIGINID='" + OID + "'";
console(sql)

//returns '' in console
var str = concatenate("'", OID, "'")

 

 

Does anyone know what is going on? I don't know enough about Arcade to even venture a guess.

0 Kudos
3 Replies
KimGarbade
Occasional Contributor III

If you are using a table "Joined" to the feature class the syntax is like this (I.E. $feature['tablename.attributename']:

"Attribute from feature class: " + $feature['CityTestPoints.CityName'] + TextFormatting.NewLine + "Attribute from joined table: " + $feature['TestData.TestField']

 gives you: 

KimGarbade_0-1650227717581.png

Is this what you are asking about, or are you using a relationship class to associated the feature class with the related table data?

0 Kudos
Glasnoct
New Contributor III

I'm not trying to generate a label in the map, if that's how the problem came across. I'm very new to ArcPro and so there are unknown unknowns about how everything is tied together in the database we're using but I believe it's the latter, a relationship class. The heirarchy in the attribute pane is

kylehurst_1-1650248995767.png

A new relationship is created in the tertiary splitter and that relationship is then added to the input or output section of the secondary splitter feature. "name to be changed" is related to the two objects (?) but neither of the splitters are related to each other. "name to be changed" has a field value equal to the tertiary's GID and I want to replace "name to be changed" with values from the tertiary so I can at a glance tell what tertiary splitters are related to the secondary without all the clicking.

 

0 Kudos
Glasnoct
New Contributor III

This code verifies. I had to put in an if clause because trying to validate it without a case that $feature.ORIGIN_ID was null, it would not, in which case currently it just falls back to a static ID for debugging purposes.

//'0CF9D009-B25C-4F7C-BA45-7FB1CA76D925'
var GID = Iif(IsEmpty($feature.ORIGIN_GID), '0CF9D009-B25C-4F7C-BA45-7FB1CA76D925', $feature.ORIGIN_GID);
var fs = FeatureSetByName($datastore,"FiberSplitter");
var sql = "GLOBALID='{" + GID + "}'";
var result = First(Filter(fs, sql))
var displayname = when(
result.SPLITTER_ORDER == 1, "Primary 1x" + result.SPLITTER_RATIO,
result.SPLITTER_ORDER == 2, "Secondary 1x" + result.SPLITTER_RATIO,
result.SPLITTER_ORDER == 3, "Tertiary 1x" + result.SPLITTER_RATIO,
"Splitter"
)
console(displayname + " (" + result.OBJECTID + ")")
return displayname

kylehurst_0-1650303291447.png

 

I've successfully retrieved the info I'm looking for but the display name won't actually update in the attribute pane and I don't know if perhaps the expression is too computationally expensive and Arc defaults back as a result? Is that a thing? The display option in the table properties is actually blank when I check versus <expression> like it is for other custom labels.

kylehurst_1-1650303513843.png

 

 

0 Kudos