<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Push a feature in a featureSet - Arcade script in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/push-a-feature-in-a-featureset-arcade-script/m-p/1342726#M1285</link>
    <description>&lt;P&gt;Thank you, it helped solve my issue !&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2023 15:38:19 GMT</pubDate>
    <dc:creator>HamzaMerini</dc:creator>
    <dc:date>2023-10-27T15:38:19Z</dc:date>
    <item>
      <title>Push a feature in a featureSet - Arcade script</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/push-a-feature-in-a-featureset-arcade-script/m-p/1342575#M1283</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I would like to add features in a featureSet, I initialize a featureSet and depending on other features I would like to push elements of these features on conditions :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var myFeatureSet = FeatureSet({
    layerDefinition: {
        objectIdField: "FID",
        geometryType: "esriGeometryPolygon",
        fields: [
            { name: "FID", alias: "FID", type: "esriFieldTypeOid" },
            { name: "attributeX", alias: "attributeX", type: "esriFieldTypeDate" },
            { name: "attributeY", alias: "attributeY", type: "esriFieldTypeString" }
        ]
    },
    featureset: {
        features: [Feature(null, "FID", 1, "attributeX", "Hello World")]
    }
});

var features = FeatureSetByName($map, myLayer,["*"],false)
var filteredFeature = Filter(features,
     'attributeZ is not null')

for(var feat in filteredFeature){
// Push the feat in myFeatureSet
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to do it with Push function but I get Invalid Input ERROR&lt;BR /&gt;&lt;BR /&gt;How can I do it ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 10:27:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/push-a-feature-in-a-featureset-arcade-script/m-p/1342575#M1283</guid>
      <dc:creator>HamzaMerini</dc:creator>
      <dc:date>2023-10-27T10:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Push a feature in a featureSet - Arcade script</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/push-a-feature-in-a-featureset-arcade-script/m-p/1342676#M1284</link>
      <description>&lt;P&gt;Your code doesn't follow the way that a FeatureSet is established, according to the docs.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featureset" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featureset&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Try defining the geometryType, fields, and features, but don't nest them in separate layerDefinition an dfeatureset objects.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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"}}
  ]
};&lt;/LI-CODE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 27 Oct 2023 14:45:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/push-a-feature-in-a-featureset-arcade-script/m-p/1342676#M1284</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-10-27T14:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Push a feature in a featureSet - Arcade script</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/push-a-feature-in-a-featureset-arcade-script/m-p/1342726#M1285</link>
      <description>&lt;P&gt;Thank you, it helped solve my issue !&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 15:38:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/push-a-feature-in-a-featureset-arcade-script/m-p/1342726#M1285</guid>
      <dc:creator>HamzaMerini</dc:creator>
      <dc:date>2023-10-27T15:38:19Z</dc:date>
    </item>
  </channel>
</rss>

