<?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 script to colour polygons in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1472997#M59196</link>
    <description>&lt;P&gt;Does the editor show you a message if you over over the red sections? Usually that would mean there's something wrong with the field name.&lt;/P&gt;&lt;P&gt;If the field really is "Survey_2021", try using bracket notation, like &lt;STRONG&gt;$feature['Survey_2021']&lt;/STRONG&gt; instead. Capitalization counts!&lt;/P&gt;</description>
    <pubDate>Wed, 15 May 2024 16:13:37 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2024-05-15T16:13:37Z</dc:date>
    <item>
      <title>Arcade script to colour polygons</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1471999#M59190</link>
      <description>&lt;P&gt;Hello, I am trying to add styling to my polygon layer using values in two different fields.&amp;nbsp; I am new to Arcade and a coding amateur at best.&amp;nbsp; I can get it to work by adding another duplicate layer to my web map and colouring it green if there's something in the Date field, but I want to avoid having to add extra un-necessary layers/complication to my web map.&lt;/P&gt;&lt;P&gt;So, to summise:&lt;/P&gt;&lt;P&gt;Field 1 - To Be Assessed&amp;nbsp; - This is a Y or N text field - pre-populated.&lt;/P&gt;&lt;P&gt;Field 2 - Date Assessed -&amp;nbsp;This is a Date Field - empty to start with, to be filled in by the surveyor.&lt;BR /&gt;-----------------------------------------&lt;/P&gt;&lt;P&gt;If field 1 = Y - colour polygon RED&lt;/P&gt;&lt;P&gt;If field 1 = N - colour polygon BLUE&lt;/P&gt;&lt;P&gt;If field 2 is not null, or has a date in it, colour polygon GREEN&lt;/P&gt;&lt;P&gt;So far I have got as far as the below but I am not getting it to work:&lt;/P&gt;&lt;P&gt;----------------------------------------&lt;/P&gt;&lt;P&gt;var survey = $feature['Survey_2024'];&lt;BR /&gt;var result = "";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If (IsEmpty(survey)) {Console("SURVEY=?");}&lt;/P&gt;&lt;P&gt;else if (survey == 'N') {result += "NO SURVEY";}&lt;/P&gt;&lt;P&gt;else {result += "YES - SURVEY REQUIRED";}&lt;/P&gt;&lt;P&gt;if (isEmpty($feature.Date_Assessed)) { } else&lt;BR /&gt;{result += "COMPLETE";}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;result = Trim(result);&lt;BR /&gt;if (result=="") {&lt;BR /&gt;result = "No Data";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return result;&lt;/P&gt;&lt;P&gt;Grateful for any help!&amp;nbsp; Many thanks, Harry&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 08:29:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1471999#M59190</guid>
      <dc:creator>HarryBell</dc:creator>
      <dc:date>2024-05-15T08:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade script to colour polygons</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1472882#M59193</link>
      <description>&lt;P&gt;Your pseudo-code makes it pretty easy to understand.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;If field 1 = Y - colour polygon RED&lt;BR /&gt;If field 1 = N - colour polygon BLUE&lt;BR /&gt;If field 2 is not null, or has a date in it, colour polygon GREEN&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;When you have a series of conditions, the function &lt;STRONG&gt;When&lt;/STRONG&gt; is your friend. The conditions will evaluate in order, so put the most important ones first. And you need to include a fallback option at the end.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return When(
  !IsEmpty($feature.field_2), 'Green',
  $feature.field_1 == 'Y', 'Red',
  $feature.field_1 == 'N', 'Blue',
  'Other'
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Note that this will give you &lt;EM&gt;categories&lt;/EM&gt;, but won't directly define the color. You'll need to open up each category and configure the symbol settings accordingly.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 14:08:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1472882#M59193</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-05-15T14:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade script to colour polygons</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1472992#M59195</link>
      <description>&lt;P&gt;Hi Josh&lt;/P&gt;&lt;P&gt;Wow - that makes it look easy!&amp;nbsp; I've tried putting it in as is, but it has the red blocks and doesn't let me save it - have I missed something?&amp;nbsp; Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HarryBell_0-1715789236876.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/104192iAF64691F6598AB59/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HarryBell_0-1715789236876.png" alt="HarryBell_0-1715789236876.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 16:07:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1472992#M59195</guid>
      <dc:creator>HarryBell</dc:creator>
      <dc:date>2024-05-15T16:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade script to colour polygons</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1472997#M59196</link>
      <description>&lt;P&gt;Does the editor show you a message if you over over the red sections? Usually that would mean there's something wrong with the field name.&lt;/P&gt;&lt;P&gt;If the field really is "Survey_2021", try using bracket notation, like &lt;STRONG&gt;$feature['Survey_2021']&lt;/STRONG&gt; instead. Capitalization counts!&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 16:13:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-script-to-colour-polygons/m-p/1472997#M59196</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-05-15T16:13:37Z</dc:date>
    </item>
  </channel>
</rss>

