OpenNTF.org - Delete Private Views on exitin
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Delete Private Views on exiting 
Rating:
Not Rated Yet 
Contributor:
Joseph LeMay 
Category:
Lotusscript 
Type:
API Functions 
Notes Version:
R5.x, R6.x 
Last Modified:
23 Jun 2004 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Disclaimer: I didn't write this, but got if off of the user forums at notes.net. It works really well.



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

Usage / Example
Put the above code in a script library called "Private Views" then, in the database QueryClose event have Use "Private Views"

in the Options section
and

Call DeletePrivateView(db, "View Name")

in QueryClose
 Comments

No documents found

 Add your comment!