Hello
i am having somme trouble getting the feature attribute when i use this syntaxe: feature.attribute
// get the feature with the highest id
var s = FeatureSetByName($datastore,"patrimoine",['*'],false);
var k= $feature.code_pat2
var p = filter( s,'code_pat2 = @k')
var max_feature = First(OrderBy(p, "code_avis DESC"))
// get the number of that id
return max_feature.code_avis
"code_avis" is an attribute in the feature "max_feature"
in the expression builder of arcade in arcgis pro the syntax is valide
but when i want to save the attribute rules i get this message
note that isempty (max_feature) = false
and
texte (max_feature) = {"geometry":null,"attributes":{"code_avis":"PAT0010-03","code_pat":"PAT0009","code_pat2":"PAT0010","GlobalID":"{9FAFFFA1-4E28-4733-B498-EE8FA3BD9E8E}","numero":null,"OBJECTID":54,"obs":"6545"}}
that mean it is not an empty feature and the value i should get as return is "PAT0010-03"
how can i solve this problème
thanks
I'm surprised that this expression is shown as valid. Normally, this error should be shown in the validation.
The normal way to solve that error is to check if the feature returned with First() is null (meaning an empty feature set) and returning a default value if so.
var max_feature = First(OrderBy(p, "code_avis DESC"))
if(max_feature == null) {
return null
}
return max_feature.code_avis