Trying to access a feature's attribute using the bracket notation does not work when using a variable (unless it is accessed at least once using a string.
If you take a look at the snippet below. This gives an error
var fldName = "ASSETTYPE";
Console($feature[fldName]);
The error message is :
Invalid expression.
Error on line 2.
Field not found ASSETTYPE
While If I try to use the snippet below. It works without an error
var ftrValue = $feature["ASSETTYPE"];
Console(ftrValue);
var fldName = "ASSETTYPE";
Console($feature[fldName]);
Any ideas how I can work around this restriction? I have a dynamic list of fields that I am trying to use to get values from the feature.
One thing to note is that if I use OBJECTID for the first snippet, it does not give any errors and works without having to access the field first using an inline string!