Server is running low on disk space, no $ to increase disk space b/c they keep hiring more mgrs
I’m trying to loop through all dbs on a server and remove any replication conflicts to save space.
In my code, when it gets to:
Set collection = db.AllDocuments
nothing is returned, therefore:
Set doc = collection.GetFirstDocument()
yields nothing as well
Full script is below, any ideas?
TIA,
-MC
Option Public
Option Explicit
Const server=“Servername/DOMAIN”
Sub Initialize
On Error Resume Next
Dim session As New notessession
Dim server_directory As NotesDbDirectory
Dim db As NotesDatabase
Set server_directory=session.getdbdirectory(server)
Set db=server_directory.getfirstdatabase(DATABASE)
While Not (db Is Nothing)
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set collection = db.AllDocuments
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)
If doc.HasItem("$Conflict") Then
Call doc.RemovePermanently(True)
End If
Set doc = collection.GetNextDocument(doc)
Wend
Set db=server_directory.GetNextDatabase()
Wend
End Sub
Subject: “Set collection = db.AllDocuments” returns nothing
When you use the NotesDbDirectory to get a database, you normally have to call db.Open explicitly before you can get at its innards.
Subject: RE: “Set collection = db.AllDocuments” returns nothing
Call db.Open( “”, “” )
did the trick!
the only problems at this point are:
a. it doesn’t grab any conflicts that have already been moved to trash and
a. it does a soft delete and moves the docs to trash so now I have to wade through the trash folder and manually remove the conflicts from there.
In a perfect world I’d like the scrript to just grab every single conflict document even if it’s already in the trash and hard delete it
possible?
TIA,
-MC
Subject: “Set collection = db.AllDocuments” returns nothing
why not use the Search method instead with the following as your select statement
sf$ = { Select @IsAvailable($Conflict) }
Set collection = db.Search(sf$, Nothing, 0)
If collection.Count > 0 Then
Print Cstr(collection.Count) & " conflict documants deleted"
Call collection.RemoveAll(True)
Else
Print “Search returned no conflict documents”
End If
This way you will get only what you need, all conflict docs.
Subject: RE: “Set collection = db.AllDocuments” returns nothing
dude that’s awesome,
I’m gonna try that
hopefully it grabs conflicts in the trash folder and deletes them as well
Subject: RE: “Set collection = db.AllDocuments” returns nothing
still doesn’t work
in the debugger, the “variables” tab shows a blank next to “collection”
thks for trying
Subject: RE: “Set collection = db.AllDocuments” returns nothing
if it’s not working then there is something wrong in your code or there are no conflicts in the db. I just ran this against my address book and it returned 3 documents in the collection. I checked my addresss book and there are indeed 3 conficts.
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
serv$ = "<your server here>"
file$ = "names.nsf"
Set db = ns.GetDatabase(serv$, file$)
sf$ = { Select @IsAvailable($Conflict) }
Set collection = db.Search(sf$, Nothing, 0)
If collection.Count > 0 Then
Print Cstr(collection.Count) & " conflict documents deleted"
' Call collection.RemoveAll(True)
Else
Print "Search returned no conflict documents"
End If
Subject: RE: “Set collection = db.AllDocuments” returns nothing
it actually does work when I add the db.Open(“”, “”) line
problem is that it doesn’t grab conflicts in the Trash folder, it also doesn’t hard delete the conflicts but rather moves them to Trash so I’m still needing to sort through and empty out the Trash manually
Can it even be done?
Subject: RE: “Set collection = db.AllDocuments” returns nothing
you’d need to loop through your doc collection and use the RemovePermanently method to delete each of them 1 by 1. But it will not get the docs in the trash. Not sure how you’d do that.
Subject: RE: “Set collection = db.AllDocuments” returns nothing
It was the db.Open call that was missing, Paul. Databases returned from the NotesDbDirectory class are not automatically opened the way they are with session.GetDatabase.