The "getProfileDocuments" agent creates a stub document for every profile document in a
database. Every newly created document has a rich text field with a doclink to a profile document.
The form used for the creation of the stub documents has AutoLaunch setting "- First Document Link"
so the user could open, edit and save the profile documents directly from view. Caution! Deleting
the stub documents from the view does not affect the profile documents. Instead, please see the
agent named deleteProfileDocuments below. Also, the paste operation in the profiles view should be
restricted through the QueryPaste event. The form and view could have supplementary fields
depending of the profile documents structure and user needs.
Create a "Profile" Form used for stub documents creation that contains the following fields: ProfileName Text UserName Text Body RichText Profile_UNID Text AutoLaunch form setting -First Document Link- Create a "ProfilesView" View used for profile documents display. The view could have the following columns: Column 1 - ProfileName Column 2 - UserName The Paste operation should be restricted in the ProfilesView view. Sub Querypaste(Source As Notesuiview, Continue As Variant) Messagebox ("You cannot paste documents in this view!") Continue = False End Sub getProfileDocuments agent: Sub Initialize Dim s As New NotesSession Dim db As New NotesDatabase("czms", "isys/isys100_.nsf") Dim vc As NotesViewEntryCollection Dim col As NotesDocumentCollection Dim doc, doc_ref As notesdocument ' get a handle to all profile documents in database Set col = db.GetProfileDocCollection("") If Not col.count = 0 Then Set doc = col.GetFirstDocument Else Messagebox ("There are no profile documents !") Exit Sub End If ' delete the previously created stub documents Set view = db.GetView( "ProfilesView" ) Set vc = view.AllEntries Call vc.RemoveAll(True) ' create stub documents While Not doc Is Nothing Set doc_ref = db.CreateDocument doc_ref.Form = "Profile" ' get the name of the profile doc doc_ref.ProfileName = doc.NameOfProfile ' get the name of the key attached to the profile doc doc_ref.UserName = Strrightback(doc.getItemValue("$Name")(0), "_") ' get the UniversalID of the profile doc - field used by deleteProfileDocuments agent doc_ref.Profile_UNID = doc.UniversalID Set rt_item = New NotesRichTextItem( doc_ref, "Body" ) ' create the doclink to the profile doc Call rt_item.AppendDocLink( doc, doc.getItemValue("$Name")(0)) Call doc_ref.save(True, True) Set doc = col.GetNextDocument(doc) Wend End Sub The "deleteProfileDocuments" agent is an example of how to delete selected profiles form the ProfilesView view. Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Dim doc_ref, doc_profile As NotesDocument Dim coll As NotesDocumentCollection Set db = s.CurrentDatabase Set coll=db.UnprocessedDocuments For i = 1 To coll.count Set doc_ref = coll.GetNthDocument(i) Set doc_profile = db.GetDocumentByUNID ( doc_ref.Profile_UNID(0) ) 'Delete profile doc doc_profile.Remove(True) 'Delete stub doc doc_ref.Remove(True) Next End Sub
This was first published in July 2001