<?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 Delete feature using attribute rules? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103430#M46170</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to delete a feature based on the length of time that passes. I am hoping to fully automate a project that we are working on so that if a certain number of days pass, then that particular feature gets deleted. I hope someone can assist. I am relatively new to attribute rules but the few that I have implemented, it has helped significantly with automating tasks.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var From = Date($feature.OutageEnd)
var To = Date(Now())
var DaysAfterOutage = DateDiff(To, From, 'days')

//Constants for defining which features to delete//
var UniqueID = $feature.GlobalID

//Define which features to delete after a given amount of time//
if (DaysAfterOutage &amp;gt;= 7){
return {
'edit':[
'deletes':[
{UniqueID}
]
]
}
}&lt;/LI-CODE&gt;&lt;P&gt;Any help on this would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Sep 2021 11:48:04 GMT</pubDate>
    <dc:creator>RPGIS</dc:creator>
    <dc:date>2021-09-30T11:48:04Z</dc:date>
    <item>
      <title>Delete feature using attribute rules?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103430#M46170</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to delete a feature based on the length of time that passes. I am hoping to fully automate a project that we are working on so that if a certain number of days pass, then that particular feature gets deleted. I hope someone can assist. I am relatively new to attribute rules but the few that I have implemented, it has helped significantly with automating tasks.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var From = Date($feature.OutageEnd)
var To = Date(Now())
var DaysAfterOutage = DateDiff(To, From, 'days')

//Constants for defining which features to delete//
var UniqueID = $feature.GlobalID

//Define which features to delete after a given amount of time//
if (DaysAfterOutage &amp;gt;= 7){
return {
'edit':[
'deletes':[
{UniqueID}
]
]
}
}&lt;/LI-CODE&gt;&lt;P&gt;Any help on this would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 11:48:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103430#M46170</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-09-30T11:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Delete feature using attribute rules?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103447#M46171</link>
      <description>&lt;P&gt;There are a number of things that would be good in this scenario but aren't possible:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You can't auto delete a feature after a certain time&lt;/LI&gt;&lt;LI&gt;You can't run a rule on a whole table, only on features&lt;/LI&gt;&lt;LI&gt;You can't run a rule on demand, only when you insert/update/delete a feature (for calculation attribute rules)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So fully automated deletion won't be possible. But there are a few things that could make it easier:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You cold symbolize features that are ready to delete differently using symbol property connections.&lt;BR /&gt;For example, you could symbolize "normal" features blue and deletable features red:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return IIF(DateDiff(Now(), $feature.OutageEnd, "days") &amp;gt;= 7, "red", "blue")​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You can use a python script to delete these features for you e.g. each night.&lt;/LI&gt;&lt;LI&gt;You can use an Attribute Rule that fires whenever you insert or update a new feature:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute rule on your feature class
// Some editable field
// Triggers: Insert, Update
// Exclude: True

// get all entries of your feature class
var fs = FeatureSetByName($datastore, "FeatureClass")

// if OutageEnd can be null, filter these values out
fs = Filter(fs, "OutageEnd IS NOT NULL")

// You could filter for the date, but the sql depends on your dbms, so I'm not going to do that. Instead, I'm going to test each feature using Arcade.
var deletes = []
for(var f in fs) {
  if(DateDiff(Now(), f.OutageEnd, "days") &amp;gt;= 7) {
    Push(deletes, {"globalID": f.GlobalID})
  }
}

return {
  "result": $feature.YourReturnField,
  "edit": [
    {
      "className": "FeatureClass",
      "deletes": deletes
    }
  ]
}​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 12:28:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103447#M46171</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-30T12:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delete feature using attribute rules?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103468#M46174</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I was really hoping that deletions on the fly were possible. I know it is very easy to do using python, since I have built several tools to delete an existing feature if it already exists. I am surprised, however, that automated deletion isn't possible even though attribute changes can be made on the fly. So I assumed that there was a way to set up a rule to automatically delete a record if the criteria were met.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 13:26:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103468#M46174</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-09-30T13:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Delete feature using attribute rules?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103840#M46222</link>
      <description>&lt;P&gt;Other than scheduling a python script to run periodically, I know of no way to do that completely automatically.&lt;/P&gt;&lt;P&gt;I think the Attribute Rule approach comes pretty close. All you have to do to execute it is insert a new feature or update an existing one.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 05:56:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/delete-feature-using-attribute-rules/m-p/1103840#M46222</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-10-01T05:56:53Z</dc:date>
    </item>
  </channel>
</rss>

