Select to view content in your preferred language

get feature attribute (error 002717, unexpecter null,invalide error) arcade

297
1
09-01-2022 10:48 PM
Labels (1)
solidsnake
Emerging Contributor

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 

solidsnake_0-1662097139841.png

but when i want to save the attribute rules i get this message

solidsnake_1-1662097229583.png

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

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

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

Have a great day!
Johannes
0 Kudos