As has been previously posted, there’s a bug in r6 with using the GetView method of the NotesDatabase class to get a handle on POFU views/folders.
http://www-1.ibm.com/support/docview.wss?rs=0&uid=swg21108323
Through testing I have found that once a Private view/folder has been created by accessing the Shared one, Formula commands such as @Command([RemoveFromFolder]) and Script such as PutAllInFolder( ) are using the Private one so putting docs into a POFU view/folder and removing them should not be a problem.
On the other hand, you might want to delete Private views/folders automatically when a user exits the database so they are cleaned up. In r5 the GetView method would grab the Private view/folder instead of the Shared one so if you wanted to delete the Private one, it was easy. With the bug in r6, others have posted workarounds (i.e. http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedWeb/0ea2fac1f4731db285256da20048c1ee?OpenDocument) to loop through all of the views and find the matching one that has something in the Readers field. The problem with this is that if the database has quite a few views or folders, it can take forever to loop through them all when the user leaves the database.
To make up for the bug, I wrote some script using Notes API calls to grab the Private view by name, get its NoteID, get it as a Document using the NotesID, and then delete it. The code below goes into the Database Script. Some of the documentation is directly from the Lotus C API Reference.
NOTE: I deleted my errorhandling routine to send emails or edit the agent log but I would definitely suggest you add your own.
'DECLARATIONS
Const APIModule = “NNOTES” ’ Windows/32 only
Const NOTE_CLASS_VIEW= &H0008
Declare Function OSPathNetConstruct Lib APIModule Alias “OSPathNetConstruct” _
( Byval NullPort As Long, Byval Server As String, Byval FIle As String, Byval PathNet As String) As Integer
Declare Function NSFDbOpen Lib APIModule Alias “NSFDbOpen” _
( Byval PathName As String, DbHandle As Long) As Integer
Declare Function NSFDbClose Lib APIModule Alias “NSFDbClose” _
( Byval DbHandle As Long) As Integer
Declare Function NIFFindPrivateDesignNote Lib APIModule Alias “NIFFindPrivateDesignNote” _
( Byval hdb As Long, Byval NoteName As String, Byval NoteClass As Integer, NoteID As Long ) As Integer
Sub DeletePrivateView(db As NotesDatabase, vname As String)
' To open a Domino database on a server, use this function to create
' the full path specification, and pass this specification as input to NSFDbOpen
' or NSFDbOpenExtended.
p$ = String(1024, " ")
OSPathNetConstruct 0, db.Server, db.FilePath, p$
' This function takes a pathname to an existing Domino database or database
' template (whether on a Lotus Domino Server or a local database), opens the
' database, and returns a handle to it. All subsequent access to the database is
' carried out via this handle. Use NSFDbClose to close the database file handle
' and deallocate the memory associated with it.
Dim hDB As Long
NSFDbOpen p$, hDB
' Given the name and NOTE_CLASS_xxx of a private design note (form, view,
' folder, helpindex, macro, field, or replication formula ), this function returns the note ID.
' Uses the View or Folder name passed to it - vname.
Dim retNoteID As Long
Dim result As Integer
result = NIFFindPrivateDesignNote(hDB, vname, NOTE_CLASS_VIEW, retNoteID)
'If result is anything other than 0, the Private Design Note could not be found
If result = 0 Then
Dim doc As NotesDocument
' Get the Private View or Folder by its NoteID
Set doc = db.GetDocumentByID( Hex$(retNoteID) )
Call doc.Remove( True )
Print "Removing : " & vname
End If
' This function closes a previously opened database.
NSFDbClose hDB
End Sub
And then in the QueryClose event, I just pass the database and view/folder name. Again, add your own errorhandling.
Sub Queryclose(Source As Notesuidatabase, Continue As Variant)
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
' Pass the name of the Private View or Folder to delete
Call DeletePrivateView(db, "Custom Query")
Call DeletePrivateView(db, "Search Results")
Call DeletePrivateView(db, "Excel Export")
End Sub
Hope this might help someone. If anyone sees a problem with it or places it could be improved, please let me know.
Bryce