Is it possible to cleanup completed jobs without manually deleting jobs? It would be nice to do a clean up and only retain x amount of days of completed jobs.
Would python be suitable for it?
Hey @ChrisBerryman
You can setup a Python script to have a date cutoff and delete certain jobs after a certain date threshold, I do this currently with Workforce points, but it may also be a good idea to move them to a separate backup table instead of fully deleting for record keeping purposes.
If you'd like a good structure on how to create this script let me know and I'll post one!
Cody
Yeah if you got an example that would be great!
Thank you!
Here's an example of the deletion process:
from arcgis.gis import GIS from dotenv import load_dotenv from datetime import datetime, timedelta load_dotenv() gis = GIS('https://<company>.com/portal', username, password) # Workforce Assignments wforce = 'id' WFwforce = gis.content.get(wforce) WFwforceLayers = WFwforce.layers wforceLayer = WFwforceLayers[0] wforce_features = wforceLayer.query().features yesterday = datetime.now() - timedelta(days=1) yesterday_hour = yesterday.replace(minute=0, second=0, microsecond=0) unix_yesterday = int(yesterday_hour.timestamp()) for item in wforce_features: item_attr = item.attributes if item_attr['completeddate'] != None: if item_attr['completeddate'] > unix_yesterday: # Delete the item
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.