I used the following Arcade code from this forum to filter out empty fields. When I run it in the Arcade console, it seems to work fine. And it worked fine when I had the "Fields list" component added to the pop-up. However, when I only have the Arcade component selected, it will not display a filtered table.
Is this a bug or is this intentional? Having two field tables would be redundant.
var flds = ['Field_1','Field_2','Field_3','Field_4','Field_5'];
var info = [];
var atts = {};
for (var i in flds) {
var fldname = flds[i];
if (!IsEmpty($feature[fldname])) {
Push (info, {'fieldName': fldname})
atts[fldname] = $feature[fldname];
}
}
return {
type: 'fields',
title: 'My Title',
description : 'My description',
fieldInfos: info,
attributes : atts
}
Solved! Go to Solution.
This is intentional behavior.
For performance reasons, Arcade only loads the fields that are needed in the expression. It does that by checking the expressions for string literals of field names ($feature.Field or $feature["Field"]).
That approach fails when you request fields dynamically like you do here. In this case, Arcade (actually probably the Javascript controlling the popup) just doesn't load any fields, because it doesn't realize that you need them.
For cases like this, Arcade has the Expects() function. Here you can explicitly state which fields should be available. For convenience, you can also use a wildcard.
Just put this at the start of your expression:
Expects($feature, "*")
This is intentional behavior.
For performance reasons, Arcade only loads the fields that are needed in the expression. It does that by checking the expressions for string literals of field names ($feature.Field or $feature["Field"]).
That approach fails when you request fields dynamically like you do here. In this case, Arcade (actually probably the Javascript controlling the popup) just doesn't load any fields, because it doesn't realize that you need them.
For cases like this, Arcade has the Expects() function. Here you can explicitly state which fields should be available. For convenience, you can also use a wildcard.
Just put this at the start of your expression:
Expects($feature, "*")
Exactly what I needed. Thank you!