It would be great if it were possible the schedule a the clean up geoprocessing history in a project. For example, in the Geoprocessing Options I could set GP history older than 2 weeks to be deleted. If this is not possible then make the GP history accessible via arcpy which can then be cleaned programmatically. I understand that technically this can be done by manipulating the files that make up the APRX but I would prefer not to mess around with them that way to avoid breaking things.
@KoryKramer- apologies for not responding sooner, I've been meaning to find the time to test this out. I've attempted to remove the GP history from an APRX file and using this approach doesn't seem to work (code below showing to 2 approaches I tried).
I did a bit of a deeper dive and it looks like the GP history is stored in the projects JSON (GISProject.json).
So really, I'd still like to see a solution available via arcpy OR via the project options.
#set the aprx obj
aprxFile = "<file path>"
aprx = arcpy.mp.ArcGISProject(aprxFile)
#check read only
if not aprx.isReadOnly:
### ATTEMPT 1 ###
#get the metadata obj
md = aprx.metadata
#delete
md.deleteContent("GPHISTORY")
#save
md.save()
aprx.metadata = md
aprx.save()
### ATTEMPT 2 ###
#get the metadata obj
md = arcpy.metadata.Metadata(aprxFile)
#delete
md.deleteContent("GPHISTORY")
#save
md.save()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.