« Fall Fell in Michigan | Main| Box of Obamas »

Kill All Profile Documents

QuickImage Category Show-n-Tell Thursday Technical LotusScript

Back 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"
'/**
' * 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
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)

enhLogAction ||, |Purging | & Cstr(collection.count) & | Profile Documents|
Call collection.RemoveAll(True)

' success!
result = True

ExitPoint:
enhLogMethodResult ||, Cstr(result)
Exit Sub
ErrorTrap:
On Error Goto 0
enhLogException ||, ||
result = False
Resume ExitPoint
End Sub ' Initialize

-Devin

Comments

Gravatar Image1 - Or just open up the db in Ytria's ScanEZ (and MartinScott's Noteman too I believe), check a box, hit delete, say ok, done.

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!

Emoticon

Gravatar Image2 - Really? Since I assume the profile document can be editted in the UI Do that, Hit Ctrl-E to put it in read more, Hit del to delete is (you will see nothing change!), close the database and confirm. No code needed ;)

Gravatar Image3 - @2 - I think you miss the point. Yes, you can edit a profile document in the UI, assuming you know the name of the profile document and you've created a an associated form with which to display / edit it.

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. Emoticon

Gravatar Image4 - It would be nice if somebody [who has the time and energy] would add this function to the Profile Document Manager that's available from OpenNTF ... { Link }

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::banghead;:cool::cry::emb::grin::huh::laugh::lips::rolleyes::sniper:;-)

Search

Wowsers! A Tag Cloud!

Links

MiscLinks