<?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 Accessing an attribute consumed by a popup in 4.xx API in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-an-attribute-consumed-by-a-popup-in-4-xx/m-p/390293#M36001</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am&amp;nbsp;new to the 4.xx API and am trying to figure out how to access an attribute of a feature that's being consumed by my popup. I'd been using the 3.xx API for many years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the 3.xx API I did this all the time using IdentifyTask and IdentifyParameters with dojo.dom and dojo.on in my popups, with no problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, with the 4.xx API, since the popup is now part of the MapView and you don't need all the Identify-things and dom and on to create a popup, I'm trying to figure out how to grab the value of one of the items in my popupTemplate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a feature layer as thus:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; parcelsLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
       url&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"https://jcgis.jacksongov.org/arcgis/rest/services/Cadastral/TaxParcelsTest/MapServer/0"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
       outFields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Parcel_ID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"SitusAddress"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"SitusCity"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"owner"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
       popupTemplate&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; thepopup
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And before that I have my popup template:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; thepopup &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
 title&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{SitusAddress}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
 content&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;b&amp;gt;Parcel Num:&amp;lt;/b&amp;gt; {Parcel_ID}&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Address:&amp;lt;/b&amp;gt; {SitusAddress}&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;City:&amp;lt;/b&amp;gt; {SitusCity}&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Owner:&amp;lt;/b&amp;gt; {owner}"&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So that when I click on a parcel, those 4 items are loaded into the popup. What I want to do is grab the "{Parcel_ID}" and assign its value to a variable, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var parcelnum = grab the {Parcel_ID} somehow&lt;/P&gt;&lt;P&gt;I know that Popup has a selectedFeature property, which is a Graphic which has attributes, but it's not clear to me how to grab a particular attribute. As in something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var &lt;SPAN&gt;parcelnum&lt;/SPAN&gt; = view.popup.selectedFeature.attributes[1];&lt;/P&gt;&lt;P&gt;But of course that doesn't work that way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I going about this the right way? Or if I want to do what I want to do, do I need to do it the same way I did using the 3.xx API?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:53:55 GMT</pubDate>
    <dc:creator>JohnAdams</dc:creator>
    <dc:date>2021-12-11T17:53:55Z</dc:date>
    <item>
      <title>Accessing an attribute consumed by a popup in 4.xx API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-an-attribute-consumed-by-a-popup-in-4-xx/m-p/390293#M36001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am&amp;nbsp;new to the 4.xx API and am trying to figure out how to access an attribute of a feature that's being consumed by my popup. I'd been using the 3.xx API for many years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the 3.xx API I did this all the time using IdentifyTask and IdentifyParameters with dojo.dom and dojo.on in my popups, with no problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, with the 4.xx API, since the popup is now part of the MapView and you don't need all the Identify-things and dom and on to create a popup, I'm trying to figure out how to grab the value of one of the items in my popupTemplate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a feature layer as thus:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; parcelsLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
       url&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"https://jcgis.jacksongov.org/arcgis/rest/services/Cadastral/TaxParcelsTest/MapServer/0"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
       outFields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Parcel_ID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"SitusAddress"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"SitusCity"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"owner"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
       popupTemplate&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; thepopup
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And before that I have my popup template:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; thepopup &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
 title&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{SitusAddress}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
 content&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;b&amp;gt;Parcel Num:&amp;lt;/b&amp;gt; {Parcel_ID}&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Address:&amp;lt;/b&amp;gt; {SitusAddress}&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;City:&amp;lt;/b&amp;gt; {SitusCity}&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Owner:&amp;lt;/b&amp;gt; {owner}"&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So that when I click on a parcel, those 4 items are loaded into the popup. What I want to do is grab the "{Parcel_ID}" and assign its value to a variable, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var parcelnum = grab the {Parcel_ID} somehow&lt;/P&gt;&lt;P&gt;I know that Popup has a selectedFeature property, which is a Graphic which has attributes, but it's not clear to me how to grab a particular attribute. As in something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var &lt;SPAN&gt;parcelnum&lt;/SPAN&gt; = view.popup.selectedFeature.attributes[1];&lt;/P&gt;&lt;P&gt;But of course that doesn't work that way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I going about this the right way? Or if I want to do what I want to do, do I need to do it the same way I did using the 3.xx API?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:53:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-an-attribute-consumed-by-a-popup-in-4-xx/m-p/390293#M36001</guid>
      <dc:creator>JohnAdams</dc:creator>
      <dc:date>2021-12-11T17:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing an attribute consumed by a popup in 4.xx API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-an-attribute-consumed-by-a-popup-in-4-xx/m-p/390294#M36002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can watch the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature"&gt;Popup's selectedFeature&lt;/A&gt; property to get access to attributes of clicked feature. See &lt;A href="https://codepen.io/U_B_U/pen/NWPwGmY?&amp;amp;editable=true&amp;amp;editors=100"&gt;this test app&lt;/A&gt;&amp;nbsp;how to do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also set the content of your popupTemplate as a function. See &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content"&gt;this sdk document&lt;/A&gt;.&amp;nbsp;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;When the feature is clicked, the feature is passed as an argument to the function and provides access to the feature’s graphic and attributes.&amp;nbsp;&lt;/SPAN&gt;See &lt;A href="https://codepen.io/U_B_U/pen/MWYOaQq?editors=1000"&gt;this test app&amp;nbsp;&lt;/A&gt;how to use function for the content.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2020 18:28:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-an-attribute-consumed-by-a-popup-in-4-xx/m-p/390294#M36002</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2020-01-02T18:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing an attribute consumed by a popup in 4.xx API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-an-attribute-consumed-by-a-popup-in-4-xx/m-p/390295#M36003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, that was helpful. Setting up a watch function seems to work ... though it's tricky accessing my parcelnum variable&amp;nbsp;outside of&amp;nbsp;the watch function, which isn't ideal but I can probably work around that. My code is this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; parcelnum&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
view&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;popup&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;watch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"selectedFeature"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;view&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;popup&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;selectedFeature &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
 parcelnum &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; view&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;popup&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;selectedFeature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attributes&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Parcel_ID&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token function"&gt;alert&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Parcel num is: "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; parcelnum&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-an-attribute-consumed-by-a-popup-in-4-xx/m-p/390295#M36003</guid>
      <dc:creator>JohnAdams</dc:creator>
      <dc:date>2021-12-11T17:53:58Z</dc:date>
    </item>
  </channel>
</rss>

