Kill All Profile Documents
Category Show-n-Tell Thursday Technical LotusScriptBack off monkey-boy, I know it's not Thursday! Consider this a day late SNTT
This morning I found myself once again writing this agent. I've needed it several times in the past, but it was always such a quick one-off type of thing I never bothered throwing it in a reusable library. I posted it here so I can always find it again. I also figured somebody else might find it useful. If you like it, use it. If you don't like it, write your own.
Anyway, here's the code:
Option Public
Option Explicit
Use "enhLogClass"
Option Explicit
Use "enhLogClass"
'/**
' * Agent: KillAllProfileDocs
' * @author: Devin S. Olson
' * @created: 06 November 2009
' * @licence: WTFPL Version 2
' **/
' * Agent: KillAllProfileDocs
' * @author: Devin S. Olson
' * @created: 06 November 2009
' * @licence: WTFPL Version 2
' **/
Sub Initialize()
'/**
' * Purges all documents in the current database.
' **/
Dim nses As New NotesSession
' * Purges all documents in the current database.
' **/
Dim ndb As NotesDatabase
Dim collection As NotesDocumentCollection
Dim profile As NotesDocument
Dim result As Boolean
On Error Goto ErrorTrap
enhLogSetLogStackExceptions True
Set ndb = nses.CurrentDatabase
Set collection = ndb.GetProfileDocCollection()
Set profile = collection.GetFirstDocument()
While Not (profile Is Nothing)
enhLogAction ||, |Preparing to purge Profile Document with UNID: | & profile.UniversalID
enhLogAllDocItems profile
Set profile = collection.GetNextDocument(profile)
Wend ' Not (profile Is Nothing)
enhLogAllDocItems profile
Set profile = collection.GetNextDocument(profile)
enhLogAction ||, |Purging | & Cstr(collection.count) & | Profile Documents|
Call collection.RemoveAll(True)
' success!
result = True
ExitPoint:
enhLogMethodResult ||, Cstr(result)
Exit Sub
ErrorTrap:
Exit Sub
On Error Goto 0
enhLogException ||, ||
result = False
Resume ExitPoint
End Sub ' Initialize
enhLogException ||, ||
result = False
Resume ExitPoint
-Devin

The Pridelands
Chris Byrne
Show n' Tell Thursdays



Comments
Still, this can be useful even for those with those tools, since it can be shown to users or run as a scheduled process. So thanks Devin!
Posted by Kevin Pettitt At 04:18:46 PM On 11/06/2009 | - Website - |
Posted by Jeroen At 06:40:37 AM On 11/07/2009 | - Website - |
The purpose of this script is to kill ALL profile documents in a database. It is primarily used when developing / testing to quickly ensure a clean (no profile docs) setup.
Posted by Devin Olson At 09:31:20 PM On 11/07/2009 | - Website - |
Posted by Tony Austin At 07:05:51 AM On 11/08/2009 | - Website - |