<?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 Version 4.15 -&amp;gt; 4.16+ PopupTemplate error in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1264801#M80468</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm looking at updating to the latest SDK version 4.26 but getting error with the popupTemplate.content property and found that it started in 4.16.&amp;nbsp; Is there something that I would need to change in 4.16 to fix that error?&amp;nbsp;&lt;/P&gt;&lt;P&gt;In 4.15 no issue, the popup template loads.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_2-1678154806124.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64497i3F392765C90395A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YimYean_2-1678154806124.png" alt="YimYean_2-1678154806124.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then with 4.16 it doesn't load the content, just the title.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_1-1678154359280.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64496iEC73BBB8FB68E3C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YimYean_1-1678154359280.png" alt="YimYean_1-1678154359280.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;-- Code to create the FeatureLayer and assign the popup template
var featureLayer = new FeatureLayer({
	url: searchLayerInfoList[i].url,
	layerId: searchLayerInfoList[i].id,
	// configure the feature layer to return all fields
	outFields: ["*"],
	popupTemplate: getPopupTemplate(displayTitle)
   
});

-- Creating the popup template.  Fails on the content retrieval in 4.16+
function getPopupTemplate(displayTitle) {
    var template = {
        title: displayTitle,
        //content: generateCustomContent,
        content: function (target) {
            var fields = [
                {
                    "fieldName": "OBJECTID",
                    "label": "OBJECTID",
                    "visible": true
                }];
            return [{ type: "fields", fieldInfos: fields }];
        },
        actions: [customZoomAction]
    }

    template.overwriteActions = true;

    return template;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Yim&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 02:09:43 GMT</pubDate>
    <dc:creator>YimYean</dc:creator>
    <dc:date>2023-03-07T02:09:43Z</dc:date>
    <item>
      <title>Version 4.15 -&gt; 4.16+ PopupTemplate error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1264801#M80468</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm looking at updating to the latest SDK version 4.26 but getting error with the popupTemplate.content property and found that it started in 4.16.&amp;nbsp; Is there something that I would need to change in 4.16 to fix that error?&amp;nbsp;&lt;/P&gt;&lt;P&gt;In 4.15 no issue, the popup template loads.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_2-1678154806124.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64497i3F392765C90395A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YimYean_2-1678154806124.png" alt="YimYean_2-1678154806124.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then with 4.16 it doesn't load the content, just the title.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_1-1678154359280.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64496iEC73BBB8FB68E3C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YimYean_1-1678154359280.png" alt="YimYean_1-1678154359280.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;-- Code to create the FeatureLayer and assign the popup template
var featureLayer = new FeatureLayer({
	url: searchLayerInfoList[i].url,
	layerId: searchLayerInfoList[i].id,
	// configure the feature layer to return all fields
	outFields: ["*"],
	popupTemplate: getPopupTemplate(displayTitle)
   
});

-- Creating the popup template.  Fails on the content retrieval in 4.16+
function getPopupTemplate(displayTitle) {
    var template = {
        title: displayTitle,
        //content: generateCustomContent,
        content: function (target) {
            var fields = [
                {
                    "fieldName": "OBJECTID",
                    "label": "OBJECTID",
                    "visible": true
                }];
            return [{ type: "fields", fieldInfos: fields }];
        },
        actions: [customZoomAction]
    }

    template.overwriteActions = true;

    return template;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Yim&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 02:09:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1264801#M80468</guid>
      <dc:creator>YimYean</dc:creator>
      <dc:date>2023-03-07T02:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Version 4.15 -&gt; 4.16+ PopupTemplate error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1264980#M80474</link>
      <description>&lt;P&gt;Was able to re-use the popup template function example code and updated to return the content array to show that the issue is reproducible.&amp;nbsp; In below example it's using latest 4.26 SDK.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1, maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;
      PopupTemplate - use functions to set content | Sample | ArcGIS Maps SDK
      for JavaScript 4.26
    &amp;lt;/title&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.26/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.26/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;script&amp;gt;
      let populationChange;
      require(["esri/Map", "esri/views/MapView", "esri/layers/Layer"], (
        Map,
        MapView,
        Layer
      ) =&amp;gt; {
        const map = new Map({
          basemap: "dark-gray-vector"
        });

        // Create the MapView
        const view = new MapView({
          container: "viewDiv",
          map: map,
          zoom: 6,
          center: [-87, 34]
        });

        Layer.fromPortalItem({
          portalItem: {
            // autocasts as new PortalItem()
            id: "e8f85b4982a24210b9c8aa20ba4e1bf7"
          }
        }).then((layer) =&amp;gt; {
          // add the layer to the map
          map.add(layer);

          // Create a new popupTemplate for the layer and
          // format the numeric field values using the FieldInfoFormat properties. Call the custom populationChange()
          // function to calculate percent change for the county.
          const popupTemplate = {
            // autocasts as new PopupTemplate()
            title: "Population in {NAME}",
            outFields: ["*"],
            content: populationChange
          };

          layer.popupTemplate = popupTemplate;

          function populationChange(feature) {
            var content = [{type:"fields", fieldInfos: [
              {
                fieldName: "POP2010",
                format: {
                  digitSeparator: true,
                  places: 0
                }
              },
              {
                fieldName: "POP10_SQMI",
                format: {
                  digitSeparator: true,
                  places: 2
                }
              },
              {
                fieldName: "POP2013",
                format: {
                  digitSeparator: true,
                  places: 0
                }
              },
              {
                fieldName: "POP13_SQMI",
                format: {
                  digitSeparator: true,
                  places: 2
                }
              }
            ]}];
            return content;
          }
        });
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_0-1678207130568.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64554i0CD0727EE377DD1C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YimYean_0-1678207130568.png" alt="YimYean_0-1678207130568.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_1-1678207163882.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64555i04301A800BE3B17E/image-size/large?v=v2&amp;amp;px=999" role="button" title="YimYean_1-1678207163882.png" alt="YimYean_1-1678207163882.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 16:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1264980#M80474</guid>
      <dc:creator>YimYean</dc:creator>
      <dc:date>2023-03-07T16:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Version 4.15 -&gt; 4.16+ PopupTemplate error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265072#M80475</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you can no longer autocast the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-FieldsContent.html" target="_self"&gt;FieldsContent&lt;/A&gt; object. If you update your code to create and return a new instance of this class then the popup should/will work. I tested it quickly and in my test the following works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function getPopupTemplate(displayTitle) {
  const template = {
  title: displayTitle,
  content: function (target) {
    const fields = [{
      "fieldName": "Street",
      "label": "Street",
     }];
     let fieldsElement = new FieldsContent({
       fieldInfos: fields
     });
     return [fieldsElement];
    },
  }
  return template;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:54:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265072#M80475</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-03-07T17:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Version 4.15 -&gt; 4.16+ PopupTemplate error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265098#M80476</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I tried the update and the console error and popup no longer gives an error but the fields aren't loading.&amp;nbsp; Are you able to provide the full sample in case I'm missing anything.&lt;/P&gt;&lt;P&gt;From my full sample code above I made the following update.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;          function populationChange(feature) {
              require(["esri/popup/content/FieldsContent", "esri/popup/FieldInfo"], (FieldsContent, FieldInfo) =&amp;gt; {
                  let fieldInfo1 = new FieldInfo({
                      fieldName: "POP2010",
                      label: "POP 2010",
                      visible: true
                  });
                  let fieldInfo2 = new FieldInfo({
                      fieldName: "POP2013",
                      label: "POP 2013",
                      visible: true
                  });
          
                  let fieldsElement = new FieldsContent({
                      fieldInfos: [fieldInfo1, fieldInfo2]
                  });
          
                  return [fieldsElement];
              });
          }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the fields aren't displayed.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_0-1678213887021.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64579iE154C45637566D49/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YimYean_0-1678213887021.png" alt="YimYean_0-1678213887021.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:32:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265098#M80476</guid>
      <dc:creator>YimYean</dc:creator>
      <dc:date>2023-03-07T18:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Version 4.15 -&gt; 4.16+ PopupTemplate error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265118#M80477</link>
      <description>&lt;P&gt;It is working for me. Here is a codepen shows it working:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/JjarRyY?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/JjarRyY?editors=1000&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 19:22:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265118#M80477</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-03-07T19:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Version 4.15 -&gt; 4.16+ PopupTemplate error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265143#M80479</link>
      <description>&lt;P&gt;Thanks, looks like my method of importing the required FiedsContent and FieldInfo didn't work when it was used within the&amp;nbsp;populationChange function.&amp;nbsp; But once I moved it to the top as in your example that resolved the issue.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YimYean_0-1678219899495.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64588iD54EA15993EAD1B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YimYean_0-1678219899495.png" alt="YimYean_0-1678219899495.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 20:14:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/version-4-15-gt-4-16-popuptemplate-error/m-p/1265143#M80479</guid>
      <dc:creator>YimYean</dc:creator>
      <dc:date>2023-03-07T20:14:37Z</dc:date>
    </item>
  </channel>
</rss>

