<?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: Arcade Code Question for Popup.  Compare two hosted services in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-code-question-for-popup-compare-two-hosted/m-p/1233243#M48960</link>
    <description>&lt;P&gt;You're comparing&amp;nbsp;&lt;SPAN&gt;firsteventhistorySorted&amp;nbsp;and&amp;nbsp;firstplowhistorySorted. These are features from different feature sets, so they will probably never be the same. Instead, you watn to compare the eventstart attribute of both features:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var go = IIF(firsteventhistorySorted.eventstart == firstplowhistorySorted.eventstart, popupString, "")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is no guarantee that eventstart will be exactly the same in both feature sets, you will probably want to format these date values before comparing:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var date1 = Text(firsteventhistorySorted.eventstart, "Y-MM-DD HH:mm")
var date2 = Text(firstplowhistorySorted.eventstart, "Y-MM-DD HH:mm")
var go = IIF(date1 == date2, popupString, "")&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 18 Nov 2022 15:23:40 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-11-18T15:23:40Z</dc:date>
    <item>
      <title>Arcade Code Question for Popup.  Compare two hosted services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-code-question-for-popup-compare-two-hosted/m-p/1233232#M48958</link>
      <description>&lt;P&gt;I have my code below, but it doesn't seem to be functioning - it never returns any values.&amp;nbsp; Any thoughts or issue with the code?&lt;/P&gt;&lt;P&gt;I have a hosted feature layer (&lt;STRONG&gt;plowhistory&lt;/STRONG&gt;), that adds a segment each time a snow plow travels over it - it may be the same segment as well.&amp;nbsp; The &lt;STRONG&gt;plowhistory&lt;/STRONG&gt; has a field with the snow &lt;FONT color="#808080"&gt;&lt;STRONG&gt;eventstart&lt;/STRONG&gt;&lt;/FONT&gt; date.&amp;nbsp; I also have a snow event table (&lt;STRONG&gt;eventhistory&lt;/STRONG&gt;) and in one field is the &lt;FONT color="#808080"&gt;&lt;STRONG&gt;eventstart&lt;/STRONG&gt;&lt;/FONT&gt; date.&amp;nbsp; After sorting both &lt;STRONG&gt;plowhistory&lt;/STRONG&gt; and &lt;STRONG&gt;eventhistory&lt;/STRONG&gt; by descending and grabbing the first record will give me the latest event &lt;FONT color="#808080"&gt;eventstart&lt;/FONT&gt; date.&amp;nbsp; If those two equal the same &lt;FONT color="#808080"&gt;eventstart&lt;/FONT&gt; date, then create the popup detailed below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var plowhistory = Intersects(FeatureSetByPortalItem(Portal('&lt;A href="https://www.arcgis.com" target="_blank"&gt;https://www.arcgis.com&lt;/A&gt;'),"eb5bff771453481fad221128d16d5a25",0), $feature);&lt;BR /&gt;var eventhistory = FeatureSetByPortalItem(Portal('&lt;A href="https://www.arcgis.com" target="_blank"&gt;https://www.arcgis.com&lt;/A&gt;'),"0bb7f78fd9244694b7bbf1dcf9480303",1, ['eventstart'],false);&lt;/P&gt;&lt;P&gt;var plowhistorySorted = OrderBy(plowhistory, 'eventstart DSC')&lt;BR /&gt;var eventhistorySorted = OrderBy(eventhistory, 'eventstart DSC')&lt;BR /&gt;var firstplowhistorySorted = First(plowhistorySorted)&lt;BR /&gt;var firsteventhistorySorted = First(eventhistorySorted)&lt;/P&gt;&lt;P&gt;var popupString = "";&lt;/P&gt;&lt;P&gt;for (var myfeature in plowhistorySorted){&lt;BR /&gt;popupString += text(myfeature.lastserviced, 'MMM DD Y, hh:mm A') +&lt;BR /&gt;TextFormatting.NewLine + TextFormatting.NewLine&lt;BR /&gt;}&lt;BR /&gt;var go = IIF(firsteventhistorySorted == firstplowhistorySorted, popupString, "")&lt;BR /&gt;return go&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 14:58:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-code-question-for-popup-compare-two-hosted/m-p/1233232#M48958</guid>
      <dc:creator>ArmstKP</dc:creator>
      <dc:date>2022-11-18T14:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Code Question for Popup.  Compare two hosted services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-code-question-for-popup-compare-two-hosted/m-p/1233243#M48960</link>
      <description>&lt;P&gt;You're comparing&amp;nbsp;&lt;SPAN&gt;firsteventhistorySorted&amp;nbsp;and&amp;nbsp;firstplowhistorySorted. These are features from different feature sets, so they will probably never be the same. Instead, you watn to compare the eventstart attribute of both features:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var go = IIF(firsteventhistorySorted.eventstart == firstplowhistorySorted.eventstart, popupString, "")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is no guarantee that eventstart will be exactly the same in both feature sets, you will probably want to format these date values before comparing:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var date1 = Text(firsteventhistorySorted.eventstart, "Y-MM-DD HH:mm")
var date2 = Text(firstplowhistorySorted.eventstart, "Y-MM-DD HH:mm")
var go = IIF(date1 == date2, popupString, "")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Nov 2022 15:23:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-code-question-for-popup-compare-two-hosted/m-p/1233243#M48960</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-11-18T15:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Code Question for Popup.  Compare two hosted services</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-code-question-for-popup-compare-two-hosted/m-p/1233244#M48961</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;Thank you so much, this was the ticket!!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 15:34:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-code-question-for-popup-compare-two-hosted/m-p/1233244#M48961</guid>
      <dc:creator>ArmstKP</dc:creator>
      <dc:date>2022-11-18T15:34:54Z</dc:date>
    </item>
  </channel>
</rss>

