<?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: graphic.attributes is not defined in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-attributes-is-not-defined/m-p/262696#M24344</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Instead of assuming that an object (a graphic in this case) will always have a particular property, it's safer to check for its existence first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With your code, instead of trying to access graphic.attributes.OBJECTID right away, do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function zoomRow(id) {
&amp;nbsp; selectionLayer.clear();
&amp;nbsp; dojo.some(map.graphics.graphics, function (graphic) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (&lt;STRONG&gt;graphic.hasOwnProperty("attributes") &amp;amp;&amp;amp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.attributes.hasOwnProperty("OBJECTID") &amp;amp;&amp;amp;&lt;/STRONG&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.attributes.OBJECTID.toString() === id) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var selectedState = new esri.Graphic(graphic.geometry)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setAttributes(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.attributes);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionLayer.add(selectedState);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Zoom to the extent of the parcel - expand it a bit so we aren't zoomed in too close.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var stateExtent = selectedState.geometry.getExtent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(stateExtent);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:53:10 GMT</pubDate>
    <dc:creator>derekswingley1</dc:creator>
    <dc:date>2021-12-11T12:53:10Z</dc:date>
    <item>
      <title>graphic.attributes is not defined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-attributes-is-not-defined/m-p/262694#M24342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to modify the example listed below to zoom in the graphic. However, the Error Console keeps to tell me that is a error "TypeError: graphic.attributes is undefined" in the test with the red color. Please let me know if you can help point out the question.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hank&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The example (StateZoomin): &lt;/SPAN&gt;&lt;A href="http://serverapps.esri.com/javascript_examples/StateZoom.html" rel="nofollow"&gt;http://serverapps.esri.com/javascript_examples/StateZoom.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My application: &lt;/SPAN&gt;&lt;A href="http://granite.nmt.edu/~hyang/test1.html" rel="nofollow"&gt;http://granite.nmt.edu/~hyang/test1.html&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;(Please use this link to see the source code)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; function zoomRow(id){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectionLayer.clear();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dojo.some(map.graphics.graphics,function(graphic){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt; if (graphic.attributes.OBJECTID.toString() === id) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; var selectedState = new esri.Graphic(graphic.geometry).setAttributes(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphic.attributes);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectionLayer.add(selectedState);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; //Zoom to the extent of the parcel - expand it a bit so we aren't zoomed in too close.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; var stateExtent = selectedState.geometry.getExtent();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; map.setExtent(stateExtent);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; });&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 19:52:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-attributes-is-not-defined/m-p/262694#M24342</guid>
      <dc:creator>Chang-HengYang</dc:creator>
      <dc:date>2013-08-19T19:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: graphic.attributes is not defined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-attributes-is-not-defined/m-p/262695#M24343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;its probably not going to solve the specific problem you're inquiring about, but it seems problematic to me that you use the legacy dojo.require() to load most of your modules, then AMD load a few more at line 253.&amp;nbsp; is there a particular reason why you're doing this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it seems like it would be a lot more straightforward to set these properties at the beginning of your init() function at line 150 instead&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;esri.config.defaults.io.proxyUrl = "/proxy.ashx";
esri.config.defaults.io.alwaysUseProxy = false;
...
esri.config.defaults.map.zoomRate&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regarding your actual question...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;its kind hard to tell whats going on since the featureLayer which triggers the workflow isn't actually shared publicly.&amp;nbsp; perhaps you can try substituting a public service and perhaps even simplifying the code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:53:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-attributes-is-not-defined/m-p/262695#M24343</guid>
      <dc:creator>JohnGravois</dc:creator>
      <dc:date>2021-12-11T12:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: graphic.attributes is not defined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-attributes-is-not-defined/m-p/262696#M24344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Instead of assuming that an object (a graphic in this case) will always have a particular property, it's safer to check for its existence first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With your code, instead of trying to access graphic.attributes.OBJECTID right away, do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function zoomRow(id) {
&amp;nbsp; selectionLayer.clear();
&amp;nbsp; dojo.some(map.graphics.graphics, function (graphic) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (&lt;STRONG&gt;graphic.hasOwnProperty("attributes") &amp;amp;&amp;amp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.attributes.hasOwnProperty("OBJECTID") &amp;amp;&amp;amp;&lt;/STRONG&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.attributes.OBJECTID.toString() === id) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var selectedState = new esri.Graphic(graphic.geometry)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .setAttributes(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.attributes);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionLayer.add(selectedState);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Zoom to the extent of the parcel - expand it a bit so we aren't zoomed in too close.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var stateExtent = selectedState.geometry.getExtent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(stateExtent);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:53:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-attributes-is-not-defined/m-p/262696#M24344</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-11T12:53:10Z</dc:date>
    </item>
  </channel>
</rss>

