<?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 If statement in arcade (with date) in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/if-statement-in-arcade-with-date/m-p/1209598#M47712</link>
    <description>&lt;P&gt;This is my first time writing an Arcade expression and I'm having trouble!&amp;nbsp; I have a feature service of koala sightings that is maintained by volunteers. Once they have completed their data entry they select "YES"&amp;nbsp; from the YES / NO domain assigned to the "Data record complete" (string) field.&amp;nbsp; They then have to enter the current date in the "Date completed" (date) field.&lt;/P&gt;&lt;P&gt;To streamline their data entry, if&amp;nbsp;"Data record complete" = 'YES'&amp;nbsp; I would like to auto-populate "Date completed" with today's date.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Field Maps form editor, I have attempted to create a new calculated expression for the&amp;nbsp;"Date completed" field , however it has an error somewhere in the code.:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var recordcomplete = $feature["Data_record_complete"];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var todaydate = Date()&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if(recordcomplete = 'YES'){&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return todaydate;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Sep 2022 04:15:12 GMT</pubDate>
    <dc:creator>BronwenHughes</dc:creator>
    <dc:date>2022-09-05T04:15:12Z</dc:date>
    <item>
      <title>If statement in arcade (with date)</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/if-statement-in-arcade-with-date/m-p/1209598#M47712</link>
      <description>&lt;P&gt;This is my first time writing an Arcade expression and I'm having trouble!&amp;nbsp; I have a feature service of koala sightings that is maintained by volunteers. Once they have completed their data entry they select "YES"&amp;nbsp; from the YES / NO domain assigned to the "Data record complete" (string) field.&amp;nbsp; They then have to enter the current date in the "Date completed" (date) field.&lt;/P&gt;&lt;P&gt;To streamline their data entry, if&amp;nbsp;"Data record complete" = 'YES'&amp;nbsp; I would like to auto-populate "Date completed" with today's date.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Field Maps form editor, I have attempted to create a new calculated expression for the&amp;nbsp;"Date completed" field , however it has an error somewhere in the code.:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var recordcomplete = $feature["Data_record_complete"];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var todaydate = Date()&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if(recordcomplete = 'YES'){&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return todaydate;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 04:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/if-statement-in-arcade-with-date/m-p/1209598#M47712</guid>
      <dc:creator>BronwenHughes</dc:creator>
      <dc:date>2022-09-05T04:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in arcade (with date)</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/if-statement-in-arcade-with-date/m-p/1209606#M47714</link>
      <description>&lt;P&gt;Your error is in the if statement.&lt;/P&gt;&lt;P&gt;Most programming languages use "=" as assignment (var x = 3) and "==" as check for equal (x == 3 --&amp;gt; true).&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if($feature["Data_record_complete"] == "YES") {
    return Now()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While the default return value of Date() is the current date and time, I would use Now() here. It returns the same value but when reading the code it's clearer what you want to do, as you can construct arbitrary Dates with Date().&lt;/P&gt;&lt;P&gt;Also, depending on your field, you might want to use Today(), which only returns the date without the time.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1662356100112.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50443iFB7F804BA5385EE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1662356100112.png" alt="JohannesLindner_0-1662356100112.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 05:35:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/if-statement-in-arcade-with-date/m-p/1209606#M47714</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-09-05T05:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in arcade (with date)</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/if-statement-in-arcade-with-date/m-p/1209608#M47715</link>
      <description>&lt;P&gt;Gosh, that was simple solution thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 05:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/if-statement-in-arcade-with-date/m-p/1209608#M47715</guid>
      <dc:creator>BronwenHughes</dc:creator>
      <dc:date>2022-09-05T05:51:58Z</dc:date>
    </item>
  </channel>
</rss>

