As has been previously posted, there's a bug in ND6 when using the GetView method of the NotesDatabase class to get a handle on POFU views/folders. This post in Lotus.com's ND6 forum and the Using method or property of NotesView object returns error: "Index is not to be generated on server" technote document this problem.
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( <FolderName> )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 ND6, others have posted workarounds (see this post to Lotus' ND6 forum) to loop through all of the views and find the matching one that has something in the Readers field. The problem with this is 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 error handling routine to send e-mails or edit the agent log, but I would definitely suggest you add your own.
Hope this might help someone. If anyone sees a problem with it or places it could be improved, please let me know.
'DECLARATIONS Const APIModule = "NNOTES" ' Windows/32 only Const NOTE_CLASS_VIEW= &H0008 Declare Function OSPathNetConstruct Lib APIModule AliasAnd then in the QueryClose event, I just pass the database and view/folder name. Again, add your own errorhandling.
"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
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
I found that this code works fine if you work with "Shared, private on first use." But if you use "Shared, desktop private on first use," the API does not find the view and it does not work. Is there a way, using Notes R6.51, to delete in the querysave the view that is stored in the desktop?
— Adriana D.
I checked the API documentation, and here is what it states for the NIFFindPrivateDesignNote function (which is what I'm using):
"Specify NOTE_CLASS_VIEW for private folders as well as private views. However, private folders that are stored in the user's desktop file, rather than in the database, cannot be accessed by the C API. Also, the C API cannot store private folders in the user's desktop file. Private folders are stored in the user's desktop file only by the Notes user interface and only if the user does not have the access right to create private folders in the database."
A couple of things to note:
- The regression error that was introduced in R6 that forced me to write the code to delete private views/folders has apparently been corrected in 6.0.4/6.5.2 for local databases. But, I can't confirm this. See SPR # TGOO5JVEGC.
Apparently it has not been corrected for server databases (several posts on LDD r6 Forum).
- The only way I know of to delete "Shared, desktop private on first use" views/folders is to delete the icon for the database from the desktop. At that point the user will be asked to confirm, and it will delete the number of private views/folders that are found. This could possibly be automated but I haven't done that.
Do you have comments of your own? Let us know.