<?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 getObjectId of Queryresult is null in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getobjectid-of-queryresult-is-null/m-p/1215027#M78776</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;i have a problem with a graphic which i got through 2 different kind of requests. I cant perfrom the method &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#getObjectId" target="_self"&gt;getObjectId&lt;/A&gt; from the graphic. It always retruns null but in the attributes there is the objectId.&lt;/P&gt;&lt;P&gt;My first attempt was with the method &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures" target="_self"&gt;queryFeatures&lt;/A&gt; directly on the featureLayer. The problem with this was in the version of the api 4.22.0 seems to be a issue with the error handling. The request failed randomly. But with the result of this attempt i could perfrom the method getObjectId.&lt;/P&gt;&lt;P data-unlink="true"&gt;the other two attempts was with &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html" target="_self"&gt;esriRequest&lt;/A&gt;&amp;nbsp;and &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query.html#executeQueryJSON" target="_self"&gt;executeQueryJSON.&lt;/A&gt;&lt;BR /&gt;With both of these request i got all features but i cant get the objectid&amp;nbsp;although it is there.&lt;/P&gt;&lt;P data-unlink="true"&gt;I also tried to create a new Graphic with the layer from the request an i converted the result from esriRequest with fromJSON but i cant get the objectID.&lt;/P&gt;&lt;P&gt;best regards&lt;BR /&gt;nico&lt;/P&gt;</description>
    <pubDate>Thu, 22 Sep 2022 12:22:15 GMT</pubDate>
    <dc:creator>WUE_BARAL</dc:creator>
    <dc:date>2022-09-22T12:22:15Z</dc:date>
    <item>
      <title>getObjectId of Queryresult is null</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getobjectid-of-queryresult-is-null/m-p/1215027#M78776</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;i have a problem with a graphic which i got through 2 different kind of requests. I cant perfrom the method &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#getObjectId" target="_self"&gt;getObjectId&lt;/A&gt; from the graphic. It always retruns null but in the attributes there is the objectId.&lt;/P&gt;&lt;P&gt;My first attempt was with the method &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures" target="_self"&gt;queryFeatures&lt;/A&gt; directly on the featureLayer. The problem with this was in the version of the api 4.22.0 seems to be a issue with the error handling. The request failed randomly. But with the result of this attempt i could perfrom the method getObjectId.&lt;/P&gt;&lt;P data-unlink="true"&gt;the other two attempts was with &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html" target="_self"&gt;esriRequest&lt;/A&gt;&amp;nbsp;and &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query.html#executeQueryJSON" target="_self"&gt;executeQueryJSON.&lt;/A&gt;&lt;BR /&gt;With both of these request i got all features but i cant get the objectid&amp;nbsp;although it is there.&lt;/P&gt;&lt;P data-unlink="true"&gt;I also tried to create a new Graphic with the layer from the request an i converted the result from esriRequest with fromJSON but i cant get the objectID.&lt;/P&gt;&lt;P&gt;best regards&lt;BR /&gt;nico&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 12:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getobjectid-of-queryresult-is-null/m-p/1215027#M78776</guid>
      <dc:creator>WUE_BARAL</dc:creator>
      <dc:date>2022-09-22T12:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: getObjectId of Queryresult is null</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getobjectid-of-queryresult-is-null/m-p/1215154#M78783</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;FeatureLayer.queryFeatures() should work reliably. If you are seeing issues with it can you please provide me with a reproducible case?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#getObjectId" target="_self"&gt;Graphic.getObjectId()&lt;/A&gt; method does return values from the `oid` field of the layer if one exists. Not all fields that are called &lt;EM&gt;objectid&lt;/EM&gt; is the oid field of the FeatureLayer. You can get the actual oil field of your layer by checking &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField" target="_self"&gt;FeatureLayer.objectIdField.&lt;/A&gt;&amp;nbsp;This property returns the name of the layer's oid field and Graphic.getObjectId() reads values from this oid field.&lt;/P&gt;&lt;P&gt;I created this simple codepen app showcasing what I explained above:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/gOzxNBa?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/gOzxNBa?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Open the console to see the results of Graphic.getObjectId, &amp;nbsp;feature.attributes[layer.objectIdField] and&amp;nbsp;feature.attributes.OBJECTID. As you can see the first two do return the values from the OID field while OBJECTID is just another field in the layer. Hope this makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 16:07:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getobjectid-of-queryresult-is-null/m-p/1215154#M78783</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2022-09-22T16:07:39Z</dc:date>
    </item>
  </channel>
</rss>

