I noticed in my log file I had the follow message “Can’t find $BusyName field on profile” and “Invalid or nonexistent document” in my Resource Database. I found some code on this forum that looks like it will work to resolve my problem but I can’t seem to get it to work.
When I run the code it give me the following error - “Document Already exists in this collection”. Can someone help me with this code?
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim docDelete As NotesDocument
Dim Profile_Collection As NotesDocumentCollection
Dim x As Integer
Dim xDelete As Integer
Dim unidJB As String
Set db = session.CurrentDatabase
If db.CurrentAccessLevel <> Acllevel_manager Then
Messagebox “You must have manager access to use this program”,16,“Access Error”
Exit Sub
End If
Set Profile_Collection = db.GetProfileDocCollection(“calendarprofile”)
If Profile_Collection.Count = 0 Then
Messagebox “Unable to Find any CalendarProfile Documents in the Database.”,64,“Found Nothing”
Exit Sub
End If
Set doc = Profile_Collection.GetFirstDocument
xDelete = 0
x = Profile_Collection.count
Do While Not (doc Is Nothing)
If Not doc.HasItem(“$BusyName”) Then
xDelete = xDelete + 1
unidJB = doc.Universalid
Set doc = Nothing
Set docDelete = db.GetDocumentByUNID(unidJB)
Call docDelete.Remove(True)
Set Profile_Collection = db.GetProfileDocCollection(“calendarprofile”)
Set doc = Profile_Collection.GetFirstDocument
Else
Set doc = Profile_Collection.GetNextDocument(doc)
End If
Loop
Messagebox “Found " & Cstr(x) & " CalendarProfile Documents in the Database.” & Chr(13) & Chr(10) &_
“Deleted " & Cstr(xDelete) & " of them that did not have the $BusyName field.”,64,“Done”