Ah, okay. If you need to use a selector based on the decoded values, then a data expression is the way to go. Yes, you'd need to populate a dictionary. If it's literally just decoding the values, you can try this:
var portal = Portal('your-url')
var fs = FeatureSetByPortalItem(
portal,
'itemid',
0, // or whatever layer index
['region', 'type_num'],
false
)
// create vars to populate feature array
var features = [];
var feat;
for (var f in fs){
var d = Decode(
f['type_num'],
1, 'human',
2, 'human',
3, 'human',
4, 'bird',
5, 'bird',
6, 'plant',
7, 'plant',
''
)
feat = {
attributes: {
region: f['region'],
type_text: d
}
}
Push(features, feat)
}
var out_dict = {
fields: [
{name: 'region', type: 'esriFieldTypeString'},
{name: 'type_text', type: 'esriFieldTypeString'}
],
geometryType: '',
features: features
}
return FeatureSet(Text(out_dict))
- Josh Carlson
Kendall County GIS