<?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 Expression to dynamically delete points when exceeds End Date in ArcGIS Enterprise Portal Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1320018#M13935</link>
    <description>&lt;P&gt;Your expression can be simplified:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var time1 = Date($feature.enddate)
var dd = DateDiff(time1, Now(), "days")

return When(
  dd &amp;lt;= 0, "Inactive",
  dd &amp;lt;= 5, "5 days or less to expire",
  "Active"  
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have a few possibilities:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Just don't symbolize expired points. They will still be in the table, but won't show up in the map.&lt;/LI&gt;&lt;LI&gt;If your actual data is in a database, you can use an &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/an-overview-of-attribute-rules.htm" target="_blank" rel="noopener"&gt;Attribute Rule&lt;/A&gt; (doesn't work for layers hosted in AGOL). You could create an Attribute Rule on your point featureclass like the script below. That will delete all expired points every time you add a new point.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on your poit fc
// triggers: Insert
// field: empty
// exclude from application evaluation

var deletes = []
for(var f in $featureset) {
  var dd = DateDiff(f.DateField1, Now(), "days")  // replace with the name of your date field
  if(dd &amp;lt;= 0) {
    Push(deletes, {globalID: f.GlobalID})
  }
}
return {
  edit: [{
      className: "TestPoints",  // replace with the name of your point fc
      deletes: deletes
    }]
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You could also write a Python script that deletes all expired points. You can run that script manually or have it run automatically every day or so.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2023 10:59:05 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-08-18T10:59:05Z</dc:date>
    <item>
      <title>Arcade Expression to dynamically delete points when exceeds End Date</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1320002#M13934</link>
      <description>&lt;P&gt;I have a point layer used for request work permits and I created a Web Application. I symbolized points using Arcade expression according to the expire date. But now user wants to expired points to be deleted. Does someone has some idea how to do it and help me? Thank you!&lt;/P&gt;&lt;P&gt;Currently my Arcade looks as in attachment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 09:38:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1320002#M13934</guid>
      <dc:creator>JonDolphin</dc:creator>
      <dc:date>2023-08-18T09:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression to dynamically delete points when exceeds End Date</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1320018#M13935</link>
      <description>&lt;P&gt;Your expression can be simplified:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var time1 = Date($feature.enddate)
var dd = DateDiff(time1, Now(), "days")

return When(
  dd &amp;lt;= 0, "Inactive",
  dd &amp;lt;= 5, "5 days or less to expire",
  "Active"  
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have a few possibilities:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Just don't symbolize expired points. They will still be in the table, but won't show up in the map.&lt;/LI&gt;&lt;LI&gt;If your actual data is in a database, you can use an &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/an-overview-of-attribute-rules.htm" target="_blank" rel="noopener"&gt;Attribute Rule&lt;/A&gt; (doesn't work for layers hosted in AGOL). You could create an Attribute Rule on your point featureclass like the script below. That will delete all expired points every time you add a new point.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on your poit fc
// triggers: Insert
// field: empty
// exclude from application evaluation

var deletes = []
for(var f in $featureset) {
  var dd = DateDiff(f.DateField1, Now(), "days")  // replace with the name of your date field
  if(dd &amp;lt;= 0) {
    Push(deletes, {globalID: f.GlobalID})
  }
}
return {
  edit: [{
      className: "TestPoints",  // replace with the name of your point fc
      deletes: deletes
    }]
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You could also write a Python script that deletes all expired points. You can run that script manually or have it run automatically every day or so.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 10:59:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1320018#M13935</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-08-18T10:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression to dynamically delete points when exceeds End Date</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1320082#M13936</link>
      <description>&lt;P&gt;I really like Johannes ' idea to leave Expired points unsymbolized.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise I would suggest a scheduled Python script that would examine the age of all the points and remove or archive the expired points.&amp;nbsp; To maintain a history I think it would be best to archive the expired points or leave them unsymbolized.&amp;nbsp; &amp;nbsp;To archive the points your Python script should copy the points to a new feature class before deleting them.&lt;/P&gt;&lt;P&gt;Bernie.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 16:15:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1320082#M13936</guid>
      <dc:creator>berniejconnors</dc:creator>
      <dc:date>2023-08-23T16:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression to dynamically delete points when exceeds End Date</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1321679#M13945</link>
      <description>&lt;P&gt;Hi Johannes, many thanks for your suggestions. I used the strategy to not showing expired permits but user is not pleased. So I'll try the python option which looks a good option.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 15:21:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-dynamically-delete-points/m-p/1321679#M13945</guid>
      <dc:creator>JonDolphin</dc:creator>
      <dc:date>2023-08-23T15:21:00Z</dc:date>
    </item>
  </channel>
</rss>

