There are a number of things that would be good in this scenario but aren't possible:
- You can't auto delete a feature after a certain time
- You can't run a rule on a whole table, only on features
- You can't run a rule on demand, only when you insert/update/delete a feature (for calculation attribute rules)
So fully automated deletion won't be possible. But there are a few things that could make it easier:
- You cold symbolize features that are ready to delete differently using symbol property connections.
For example, you could symbolize "normal" features blue and deletable features red:
return IIF(DateDiff(Now(), $feature.OutageEnd, "days") >= 7, "red", "blue")
- You can use a python script to delete these features for you e.g. each night.
- You can use an Attribute Rule that fires whenever you insert or update a new feature:
// 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") >= 7) {
Push(deletes, {"globalID": f.GlobalID})
}
}
return {
"result": $feature.YourReturnField,
"edit": [
{
"className": "FeatureClass",
"deletes": deletes
}
]
}
Have a great day!
Johannes