<?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 Map Viewer popup: Confitional popup? change popup based on one data in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1649453#M66298</link>
    <description>&lt;P&gt;Hi, I have two different set of fields and want to switch them based on one data. Is this possible?&lt;/P&gt;</description>
    <pubDate>Wed, 10 Sep 2025 17:47:37 GMT</pubDate>
    <dc:creator>YukoYokozawa</dc:creator>
    <dc:date>2025-09-10T17:47:37Z</dc:date>
    <item>
      <title>Map Viewer popup: Confitional popup? change popup based on one data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1649453#M66298</link>
      <description>&lt;P&gt;Hi, I have two different set of fields and want to switch them based on one data. Is this possible?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Sep 2025 17:47:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1649453#M66298</guid>
      <dc:creator>YukoYokozawa</dc:creator>
      <dc:date>2025-09-10T17:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Map Viewer popup: Confitional popup? change popup based on one data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1649485#M66299</link>
      <description>&lt;P&gt;You can use an Arcade element to do this.&lt;/P&gt;&lt;P&gt;In this example I am testing whether a feature has the attribute "Fish and Benthic" (line 14). This field has a domain, so I have to get the Domain Name ( line 12). If the feature does have that attribute, I want the display to contain the five fields in the line 16. Otherwise, it will contain the three fields in line 22.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fields = Schema($feature).fields;
var attributes = {};
var fieldInfos = [];

function fieldTest(fieldList, fieldName, fieldAlias) {
  if (Includes(fieldList, fieldAlias)) {
    attributes[fieldalias] = $feature[fieldName];
    Push(fieldInfos, { fieldName: fieldAlias });
  }
}

var code = DomainName($feature, "Survey");
for (var i in fields) {
  if (code == "Fish and Benthic")
    fieldTest(
      ["Site ID", "Fish Status", "Fish Date", "Benthic Status", "Benthic Date"], //the list of fields you'd like if the feature has this attribute
      fields[i].name,
      fields[i].Alias
    );
  else
    fieldTest(
      ["Site ID", "Fish Status", "Fish Date"], //the list of fields you'd like if the feature doesn't have that attribute
      fields[i].name,
      fields[i].alias
    );
}

return { type: "fields", fieldInfos: fieldInfos, attributes: attributes };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;These are what the two popups look like&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-09-10_14-57-12.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/140216i6804F23F45DFFCC8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2025-09-10_14-57-12.PNG" alt="2025-09-10_14-57-12.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="2025-09-10_14-57-28.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/140217i8DAF65AEF17C9314/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2025-09-10_14-57-28.PNG" alt="2025-09-10_14-57-28.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 10 Sep 2025 19:03:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1649485#M66299</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-09-10T19:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Map Viewer popup: Confitional popup? change popup based on one data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1649916#M66310</link>
      <description>&lt;P&gt;Thanks for reply! I tried your code and was able to show two separate popups by data like your sample. But the data don't show up... And the field orders are not what I want.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YukoYokozawa_0-1757625806496.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/140293i6D6A7669128FD42B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YukoYokozawa_0-1757625806496.png" alt="YukoYokozawa_0-1757625806496.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm using Uni PI AF for the condition, and if it's "Single", then this popup without P2 show up, and other than single, this popup show up. So, the single and dual is the only data show up nothing else. And the number in the pink circle is the order I want to see in the table. Attached the code I used.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2025 21:28:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1649916#M66310</guid>
      <dc:creator>YukoYokozawa</dc:creator>
      <dc:date>2025-09-11T21:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Map Viewer popup: Confitional popup? change popup based on one data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1650053#M66314</link>
      <description>&lt;P&gt;When posting code, please use the &lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633#U1007633" target="_self"&gt;"Insert/edit code sample"&lt;/A&gt; button. It makes reading your code much easier.&lt;/P&gt;&lt;P&gt;I don't know why it's returning empty attributes for those fields. Have you checked the FeatureSet to see if there are records with no values in the attributes?&lt;/P&gt;&lt;P&gt;The code returns the fields as they are ordered in the FeatureSet. To use a custom order, use this code&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fields = Schema($feature).fields;
var attributes = {};
var fieldInfos = [];

var fieldList;
if ($feature.UNIT_PI_AF == "Single") {
  fieldList = ["Site ID", "Unit PI AF", "Pressure URL", "Battery URL", "P1 Pressure", "P1 High High Alarm", "P1 High Alarm", "P1 High Alarm (Derived)", "P1 Low Alarm", "P1 Low Alarm (Derived)", "P1 Low Low Alarm", "Last Update PI"];
} else {
  fieldList = ["Site ID", "Unit PI AF", "Pressure URL", "Battery URL", "P1 Pressure", "P1 High High Alarm", "P1 High Alarm", "P1 High Alarm (Derived)", "P1 Low Alarm", "P1 Low Alarm (Derived)", "P1 Low Low Alarm", "P2 Pressure", "P2 High High Alarm", "P2 High Alarm", "P2 High Alarm (Derived)", "P2 Low Alarm", "P2 Low Alarm (Derived)", "P2 Low Low Alarm", "Last Update PI"];
}

for (var j of fieldList) {
  for (var i in fields) {
    if (fields[i].name == j || fields[i].alias == j) {
      attributes[fields[i].alias] = $feature[fields[i].name];
      Push(fieldInfos, { fieldName: fields[i].alias });
    }
  }
}

return { type: "fields", fieldInfos: fieldInfos, attributes: attributes };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Sep 2025 13:51:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1650053#M66314</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-09-12T13:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Map Viewer popup: Confitional popup? change popup based on one data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1650220#M66321</link>
      <description>&lt;P&gt;Hi! Thanks for your reply. With your code samples, I made some progress but not be able to complete by myself. One of my team members helped me complete the code, and it's now working. Thank you very much for your help. Here is the code that working now.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var fields = Schema($feature).fields;
var fieldInfos = []
var sortedFieldInfos = []
var attributes = {}
var unitPIAF = $feature.UNIT_PI_AF
var visibleFields = ["SITEID", "UNIT_PI_AF", "PRESSURE_URL", "BATTERY_VOLT_URL", "P1_PRESSURE", "P1_HIHI_ALARM", 
    "P1_HI_ALARM", "P1_HI_ALARM_DERIVED", "P1_LO_ALARM", "P1_LO_ALARM_DERIVED", "P1_LOLO_ALARM", "LAST_UPDATE_PI"]

if(unitPIAF != "Single") {
  visibleFields = ["SITEID", "UNIT_PI_AF", "PRESSURE_URL", "BATTERY_VOLT_URL", "P1_PRESSURE", "P1_HIHI_ALARM", 
    "P1_HI_ALARM", "P1_HI_ALARM_DERIVED", "P1_LO_ALARM", "P1_LO_ALARM_DERIVED", "P1_LOLO_ALARM", "P2_PRESSURE", "P2_HIHI_ALARM", 
    "P2_HI_ALARM", "P2_HI_ALARM_DERIVED", "P2_LO_ALARM", "P2_LO_ALARM_DERIVED", "P2_LOLO_ALARM", "LAST_UPDATE_PI"]
} 
for (var i in fields) {
  var field = fields[i]
  var fieldName = field.name
  var fieldAlias = field.alias
  if (Includes(visibleFields, fieldName)) {
    Push(fieldInfos, {fieldName: fieldName, label: fieldAlias})
    if (field.type == "esriFieldTypeDate") {
      attributes[fieldName] = Text($feature[fieldName], 'MM/DD/YYYY hh:mm:ss')
    } else {
      attributes[fieldName] = $feature[fieldName]
    }
  }
}
for (var j in visibleFields) {
  for (var k in fieldInfos) {
    if (fieldInfos[k].fieldName == visibleFields[j]) {
      push(sortedFieldInfos, fieldInfos[k])
    }
  }
}

return {
    type: 'fields',
    fieldInfos:  sortedFieldInfos,
    attributes: attributes
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Sep 2025 22:50:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/map-viewer-popup-confitional-popup-change-popup/m-p/1650220#M66321</guid>
      <dc:creator>YukoYokozawa</dc:creator>
      <dc:date>2025-09-12T22:50:07Z</dc:date>
    </item>
  </channel>
</rss>

