Your code doesn't follow the way that a FeatureSet is established, according to the docs.
https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featureset
Try defining the geometryType, fields, and features, but don't nest them in separate layerDefinition an dfeatureset objects.
var fs_json = {
geometryType: "esriGeometryPolygon",
fields: [
{ name: "FID", alias: "FID", type: "esriFieldTypeOid" },
{ name: "attributeX", alias: "attributeX", type: "esriFieldTypeDate" },
{ name: "attributeY", alias: "attributeY", type: "esriFieldTypeString" }
],
features: [
{attributes: {FID: 1, attributeX: "Hello World"}}
]
};
Also, once your FeatureSet is created, you won't be able to push features into it. You'll need to add the features to a dictionary, then create the FeatureSet once all your features have been loaded in.
var features = FeatureSetByName($map, myLayer, ['*'], false)
var filteredFeature = Filter(features, 'attributeZ is not null')
for ( var feat in feilteredFeature) {
Push(
fs_json['features'],
{
attributes: {
FID: feat['FID'],
attributeX: feat['attributeX'],
attributeY: feat['attributeY']
},
geometry: Geometry(feat)
}
)
}
return FeatureSet(fs_json)
- Josh Carlson
Kendall County GIS