<?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 Cannot set properties of undefined (setting 'OBJECTID') in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-set-properties-of-undefined-setting/m-p/1404477#M84192</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I am creating a new feature layer based on a spatial query. The query is fine. It selects the features&amp;nbsp; can see it in console.log&lt;/P&gt;&lt;P&gt;2. Created a new feature layer out of this queried results, also works perfect&amp;nbsp; &amp;nbsp;can see the feature layer attributes in console too&lt;/P&gt;&lt;P&gt;3. When I am trying to add this layer to the map,&amp;nbsp; it produces an error&amp;nbsp; "Cannot set properties of undefined (setting 'OBJECTID')" and stops. Any help please&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query.executeQueryJSON(searchUrl, queryObj).then(function (results) {
                    console.log(results.features.length);
                    //new feature layer to put selected features
                    selSketch = new FeatureLayer({ id: "selSketchLayer", outfields:"[*]" });
                    if (results.features.length &amp;gt; 999) {
                        alert("Max Record Count more than 1000. Please Select smaller area !!!");
                        deleteSketch();
                        return;
                    };
                    skfeatures = results.features;
                    var fields = results.fields;
                    selSketch.source = results.features;
                    selSketch.fields = fields;
                    selSketch.objectIdField = "OBJECTID";
                    selSketch.renderer = selSketchRenderer;
                    app.map.remove(Rerdlayer);
                    app.map.add(selSketch);&lt;/LI-CODE&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;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Error" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/99728i3450036B18CEFE48/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="Error" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Error&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2024 10:45:55 GMT</pubDate>
    <dc:creator>cadgism</dc:creator>
    <dc:date>2024-04-02T10:45:55Z</dc:date>
    <item>
      <title>Cannot set properties of undefined (setting 'OBJECTID')</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-set-properties-of-undefined-setting/m-p/1404477#M84192</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I am creating a new feature layer based on a spatial query. The query is fine. It selects the features&amp;nbsp; can see it in console.log&lt;/P&gt;&lt;P&gt;2. Created a new feature layer out of this queried results, also works perfect&amp;nbsp; &amp;nbsp;can see the feature layer attributes in console too&lt;/P&gt;&lt;P&gt;3. When I am trying to add this layer to the map,&amp;nbsp; it produces an error&amp;nbsp; "Cannot set properties of undefined (setting 'OBJECTID')" and stops. Any help please&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query.executeQueryJSON(searchUrl, queryObj).then(function (results) {
                    console.log(results.features.length);
                    //new feature layer to put selected features
                    selSketch = new FeatureLayer({ id: "selSketchLayer", outfields:"[*]" });
                    if (results.features.length &amp;gt; 999) {
                        alert("Max Record Count more than 1000. Please Select smaller area !!!");
                        deleteSketch();
                        return;
                    };
                    skfeatures = results.features;
                    var fields = results.fields;
                    selSketch.source = results.features;
                    selSketch.fields = fields;
                    selSketch.objectIdField = "OBJECTID";
                    selSketch.renderer = selSketchRenderer;
                    app.map.remove(Rerdlayer);
                    app.map.add(selSketch);&lt;/LI-CODE&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;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Error" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/99728i3450036B18CEFE48/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="Error" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Error&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 10:45:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-set-properties-of-undefined-setting/m-p/1404477#M84192</guid>
      <dc:creator>cadgism</dc:creator>
      <dc:date>2024-04-02T10:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot set properties of undefined (setting 'OBJECTID')</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-set-properties-of-undefined-setting/m-p/1404652#M84194</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;When creating a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source" target="_self"&gt;client-side FeatureLayer,&lt;/A&gt; you must set the layer's schema correctly in the layer constructor especially if the source is not set. You cannot just set fields schema to wild card. You need to set the fields schema. Since you are creating a new client-side feature layer from query results, try changing your code as shown below and see if it fixes the problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const featureSet = results.features; 
const layer = new FeatureLayer({
   source: featureSet,
   geometryType: featureSet.geometryType,
   objectIdField: "OBJECTID",
   fields: featureSet.fields,
   renderer: selSketchRenderer,
   //spatialReference: results.features[0].geometry.spatialReference
});&lt;/LI-CODE&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>Wed, 03 Apr 2024 15:25:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-set-properties-of-undefined-setting/m-p/1404652#M84194</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2024-04-03T15:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot set properties of undefined (setting 'OBJECTID')</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-set-properties-of-undefined-setting/m-p/1405050#M84205</link>
      <description>&lt;P&gt;Thank you, It Works!!!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 06:49:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-set-properties-of-undefined-setting/m-p/1405050#M84205</guid>
      <dc:creator>cadgism</dc:creator>
      <dc:date>2024-04-03T06:49:53Z</dc:date>
    </item>
  </channel>
</rss>

