When GetProfileDocCollection fails
Posted by Theo Heselmans on June 18th, 2010
I needed to loop over all profile documents to update some stuff. LotusScript has a nice method for this, called GetProfileDocCollection.
This is how you use it:
...
Set dc = db.GetProfileDocCollection("Profile")
'I only need profile documents called 'Profile'
I skip the obvious initial Dim's and Set's, as we all know them. Set dc = db.GetProfileDocCollection("Profile")
'I only need profile documents called 'Profile'
This works fine most of the time. However, if there are too many profile documents, you get the following 'self-explaining :-)' error message:
"Profile document enumeration pool is full".
Some Googling reveals this Technote. With the following remark: "This problem was reported to Quality Engineering and determined to be a software limitation." Duh ?
They offer a workaround too, but this is complete BS.
Olga Babushkina offered me a great solution, by using CreateNoteCollection. I've never had any use for this function, but I can see it's power.
Here's how to use it:
Dim nc As NotesNoteCollection
Dim noteID As String
Dim doc As NotesDocument
... 'other dim's and set's here
Set nc = db.CreateNoteCollection(False) 'this creates an empty collection of noteIDs
nc.SelectProfiles = True 'we only need profile documents
Call nc.BuildCollection 'execute the building of the notecollection
If nc.Count = 0 Then Exit Function 'bail out if nothing found
noteID = nc.GetFirstNoteId 'get the first noteid
While noteID<>""
Set doc = db.GetDocumentByID (noteID) 'now get the doc itself
If doc.form(0) = "Profile" Then 'I only want to find the profile documents called 'Profile'
'do some stuff here
End If
noteID = nc.GetNextNoteId(noteID) 'get the next noteid
Wend
Dim noteID As String
Dim doc As NotesDocument
... 'other dim's and set's here
Set nc = db.CreateNoteCollection(False) 'this creates an empty collection of noteIDs
nc.SelectProfiles = True 'we only need profile documents
Call nc.BuildCollection 'execute the building of the notecollection
If nc.Count = 0 Then Exit Function 'bail out if nothing found
noteID = nc.GetFirstNoteId 'get the first noteid
While noteID<>""
Set doc = db.GetDocumentByID (noteID) 'now get the doc itself
If doc.form(0) = "Profile" Then 'I only want to find the profile documents called 'Profile'
'do some stuff here
End If
noteID = nc.GetNextNoteId(noteID) 'get the next noteid
Wend
Using this allowed me to have access to over 7000 profile documents.
Thanks Olga, a lifesaver !
Category: Domino Notes Show-n-Tell Thursday SnTT |
Technorati: Domino, Notes, Show-n-Tell Thursday, SnTT
Comments (5)



Theo, you could also skip the doc.form(0) = "Profile" check by setting a selection formula for the NoteCollection prior to building it.
nc.SelectProfiles=True
nc.SelectionFormula={Form="Profile"}
Call nc.BuildCollection
@Nathan
Cool, there's apparently a lot I don't know about this stuff.
fantastic! This has saved me a lot of trouble too after accidentally creating hundreds of thousands of profile docs in a db!
bedankt voor deze ontzettend handige tip !
Theo, thanks for sharing this piece of code. Even though it looks short, it has potential!!