Problem with RemoveAll

I have some code that copies documents into a folder. Before doing this, the code needs to make sure all previously copied documents are removed. I simply do this with the lines:

Set vc = ReportFolder.AllEntries

Call vc.RemoveAll(True)

This works great most of the time. It does not work if the documents are categorized in the folder in such a way that a document appears in more than one category. Does anyone know how I can clear out documents in a different way that will work all the time?

Subject: Soln. for Problem with RemoveAll

Hi,

If you have records which shows in multiple times then you may have to use a little different approach in deleting all. It’s little tricky. I hope the following code will work for you.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase



Set db = session.CurrentDatabase



Dim view As NotesView



Set view = db.GetView("TEMPFOLDER")



Dim doccoll As NotesDocumentCollection

Dim entrycoll As NotesViewEntryCollection



' The following lines of code is to remove documents permanently from the folder

For index = 33 To 126

	key = Chr(index)

	Set doccoll = view.GetAllDocumentsByKey(key, False)

	If (doccoll.Count > 0) Then

		Call doccoll.RemoveAll(True)

	Else

		Print "No documents starting with: " + key

	End If

Next



' The following two lines of code is to remove all (Not Categorized" entries, if any

Set entrycoll = view.AllEntries

If (entrycoll.Count > 0) Then

	Call entrycoll.RemoveAll(True)	

End If

End Sub

Regards,

Ravi.

Subject: Removing document from more than one category

Thanks. This worked, but it is a little slow. Any idea if there are any plans for fixing this in Notes?

Subject: Another Soln. for Problem with RemoveAll

Hi,

I have another alternate solution for your problem. The performance you may have to test my previous one and this one and which one is better for you, you can use that.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim entrycoll As NotesViewEntryCollection

Dim DummyView As NotesView



Set db = session.CurrentDatabase

Set view = db.GetView("TEMPFOLDER")

Set entrycoll = view.AllEntries



If (entrycoll.Count > 0) Then

	Call entrycoll.PutAllInFolder("DUMMY-XYZ", True)

	Set DummyView = db.GetView("DUMMY-XYZ")

	Set entrycoll = DummyView.AllEntries

	Call entrycoll.RemoveAll(True)	

End If



' The following two lines of code is to remove all (Not Categorized" entries, if any

Set entrycoll = view.AllEntries

If (entrycoll.Count > 0) Then

	Call entrycoll.RemoveAll(True)	

End If	

End Sub

Regards,

Ravi.