How to Delete Profile Documents Manually or by LotusScript in Notes
A nice little "how to" from the KnowledgeBase...
How to Delete Profile Documents Manually or by LotusScript in Notes
Document Number:
1088892
Problem
Resolving problems sometimes requires
you to delete profile documents. For example, a corrupt Calendar
Profile document in a mail database can cause a Notes workstation crash
when creating a Calendar entry. Such crashes can be avoided only
by deleting the Calendar profile and recreating it. If using Notes
R4, there is also an additional Delegation Profile document which may need
to be deleted as well.
But as profile documents do not appear
in views and folders, how can profile documents be deleted?
Content
A distinction can be made between two
cases:
1. The
Profile document can be accessed for Reading/Editing directly:
If the administrator/user is in edit
mode after calling up the document, the only actions to perform are to
switch into read mode, pressing the DELETE key and the F9 key. The document
gets deleted. This method will not work for profile documents created/edited
via a Dialogbox, such as the Mail template's Calendar profile or
it's Out of Office Profile.
2. The
Profile document cannot be accessed directly, or can only be accessed via
a Dialogbox:
You can use the LotusScript GetProfileDocument
method (of the NotesDatabase class) to get a handle to a profile document,
and the Remove method (of the NotesDocument class) to delete the profile
document. Because calling the GetProfileDocument method creates a
profile document on the fly prior to deleting the document, you should
first check to see if the document previously existed. This can
be done using the IsNewNote property (of the NotesDocument class).
If the property returns True, then the profile did not exist prior to the
GetProfileDocument call and there is no need to delete it.
Beginning with Notes R5, the GetProfileDocCollection
method has been added. This allows you to get a collection of profile
documents in a database, independent of the key name used when creating
the profile document(s).
Additionally, if you know the Note ID
of a profile document, then the GetDocumentByID method (of the NotesDatabase
class) can also be used to get a handle to a Profile document.
When using the GetProfileDocument method,
you need to pass the name of the profile. If the Form the profile
is based on has an Alias name, then this should be passed as the name parameter.
Profile documents also have an optional key parameter which will
also need to be passed if it was originally created using such a key. If
the key is unknown, then the GetProfileDocCollection method could be used
instead of the GetProfileDocument method.
The Calendar profile is named "CalendarProfile".
The Notes R4 Delegation profile is "DelegationProfile".
The Out of Office profile is "OutOfOfficeProfile". In
Notes R5, the Archive properties are stored in a profile called "Archive
Profile".
Example 1, Profile document
name known:
Dim s as New NotesSession
Dim db as NotesDatabase
Dim doc as NotesDocument
Set db = s.currentdatabase
Set doc = db.GetProfileDocument(<Name
of desired profile goes here in quotes>)
Call doc.Remove(True)
Example 2, Deleting the Calendar
Profile from the current user's mail file:
Dim session as new notessession
dim db as notesdatabase
dim doc as notesdocument
'This line returns the name of the mailfile
maildbinfo = Evaluate(|@MailDbName|)
set db = session.getdatabase(maildbinfo(0),
maildbinfo(1))
set doc = db.getprofiledocument("CalendarProfile")
If Not doc.isnewnote Then Call doc.remove(true)
'This profile will only exist if using
a R4 Mail template. Including the line in R5 will cause no harm.
set doc = db.getprofiledocument("DelegationProfile")
If Not doc.isnewnote Then Call doc.remove(true)
Example 3, Accessing Profile document
by it's Note ID:
Dim session as new notessession
dim db as notesdatabase
dim doc as notesdocument
Set db = s.currentdatabase
set doc = db.getdocumentbyid("000021CA")
If Not doc is Nothing Then Call doc.remove(true)
Where 000021CA is the Note ID of the
Calendar profile.
Supporting Information:
From the On Line Help:
Retrieves or creates a profile document.
Defined in
NotesDatabase
Syntax
Set notesDocument = notesDatabase.GetProfileDocument( profilename$ [ , username$] )
Parameters
profilename$
String. The name or an alias of the profile document.
username
String. Optional. The user name (key) attached to the profile document.
Return value
notesDocument
The profile document that matches the given name.
Given a profile name, returns a collection
of profile documents that match the name.
Note This method is new with Release 5.
Defined in
NotesDatabase
Syntax
Set notesDocumentCollection = notesDatabase.GetProfileDocCollection( profilename$ )
Parameters
profilename$
String. The name of the profile document.
Return value
notesDocumentCollection
The collection of profile documents that match the given name.



Comments
Dim s as new notessession
Posted by Lim sp At 02:28:15 On 31/07/2007 | - Website - |