<?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 When function is not working in a popup in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-when-function-is-not-working-in-a-popup/m-p/1218602#M48192</link>
    <description>&lt;P&gt;Thanks! It's odd that it returned the correct value in the Test, though&lt;/P&gt;</description>
    <pubDate>Tue, 04 Oct 2022 13:18:38 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2022-10-04T13:18:38Z</dc:date>
    <item>
      <title>Arcade When function is not working in a popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-when-function-is-not-working-in-a-popup/m-p/1218593#M48189</link>
      <description>&lt;P&gt;I was helping someone with a script to split dates into quarters using a When function. This code works correctly when testing it, but the popup does not return the same results. The When function is not returning the correct value in the popup.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var theDate = Date();

var theMonth = Month(theDate); //note Month is zero-based (Jan = 0)
var quarter;

//This always returns 4 in the popup, regardless of the date
//when (theMonth &amp;lt; 3, quarter = 1,
//      theMonth &amp;lt; 6, quarter = 2,
//      theMonth &amp;lt; 9, quarter = 3,
//      quarter = 4}

when (theMonth &amp;lt; 3, quarter = 1,
      theMonth &amp;lt; 6, quarter = 2,
      theMonth &amp;lt; 9, quarter = 3,
      theMonth &amp;lt; 12, quarter = 4,
      quarter = "Fail");

return `Today's date: ${Text(theDate,"MMMM D, YYYY")}
        Today's month: ${theMonth}
        Today's quarter: ${quarter}`;&lt;/LI-CODE&gt;&lt;P&gt;When I run the Test in the code editor, it gives me the correct result.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-10-04_8-56-28.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52807i5AA1DBD573B45697/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2022-10-04_8-56-28.png" alt="2022-10-04_8-56-28.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, it does not in the popup.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-10-04_8-54-00.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52805iBB2F6C7D13CAEA9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2022-10-04_8-54-00.png" alt="2022-10-04_8-54-00.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is this a new bug?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 12:57:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-when-function-is-not-working-in-a-popup/m-p/1218593#M48189</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-10-04T12:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade When function is not working in a popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-when-function-is-not-working-in-a-popup/m-p/1218600#M48191</link>
      <description>&lt;P&gt;You have to declare the variable outside of When(). When() doesn't change any variables, it only returns a value.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var quarter = when (theMonth &amp;lt; 3, 1,
      theMonth &amp;lt; 6, 2,
      theMonth &amp;lt; 9, 3,
      theMonth &amp;lt; 12, 4,
      "Fail");&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 04 Oct 2022 13:10:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-when-function-is-not-working-in-a-popup/m-p/1218600#M48191</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-10-04T13:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade When function is not working in a popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-when-function-is-not-working-in-a-popup/m-p/1218602#M48192</link>
      <description>&lt;P&gt;Thanks! It's odd that it returned the correct value in the Test, though&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 13:18:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-when-function-is-not-working-in-a-popup/m-p/1218602#M48192</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-10-04T13:18:38Z</dc:date>
    </item>
  </channel>
</rss>

