the document to be linked, copy the document as a link, navigate back to the
document they are editing, and then paste the link into a RTF.
The following example will allow users to reset a Doclink on their current form
by using a pop-up dialog with a drop-down list of document titles. The user
selects the document they wish to link to based on the document title and a
Doclink gets generated in their current document.
A user wishes to create an Issue document and have it contain a Doclink to the
Project document for which the issue applies. Alternatively, the user may have
Created an Issue and then realized that he created a Doclink to the wrong
Project and needs to change the Doclink to another Project document.
The set up:
You will need a dialog box form for displaying the drop down list in
LotusScript since LotusScript does not provide a drop down list control.
Create the form, I will call it ?(dlgProjectPick)?. On the form create a
multi-valued text box named ?List? with the following Default value:
list := @DbColumn( "" : "NoCache" ; "" ; "Projects" ; 1 );
Where ?Projects? represents a sorted view of all Project document titles.
This field will contain the actual values displayed in our drop down list.
Also create a layout region with a combo box named Pick on the dialog form.
For the Default value of the combo box use ?List?, the multi-valued text list
we created outside the layout region.
On the Issue form create an Action button called ?Reassign Project.? Set the
button properties to Hide when the document is in edit mode since we do not
need to ?edit? the document to reassign the Doclink via LotusScript. Likewise,
preventing the use of this function from a document in edit mode prevents the
confusing ?Save? messages Notes will generate from the backend script. This
button will contain the script for presenting the new Project documents list
dialog box and assigning the newly selected document Doclink to the current
document. The form also contains a RTF named ?Link? which will hold the
DocLink. The LotusScript for the Action button appears below.
Sub Click(Source As Button)
Dim session As New notessession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
? We need to have a workspace in order to present
? the drop-down list via the dialog form
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument 'get the frontend doc
Dim backendDoc As NotesDocument
Set backendDoc = uidoc.Document 'get the backend doc
' the doclink field on our current document
Dim rtDocLink As NotesRichTextItem
' this doc will be our dialog box. Note that it is
? only used for display. It does not gets saved.
Dim docPick As New NotesDocument( db )
? Present the dialog box and continue with the Doclink
? update if the user selects a value from the list.
If ws.dialogbox( "(dlgProjectPick)", True, True, False, False, False,
False, "Select Project", docPick ) Then
'Msgbox docPick.Pick(0) 'DEBUG: verify we have the right value
' Fetch this Project and replace it in the
? doc link on this form
Dim newProjectDoc As NotesDocument
Dim view As NotesView
Set view = db.GetView( "Projects" )
Set newProjectDoc = view.GetDocumentByKey( docPick.Pick(0), True )
' Remove the old link
backendDoc.RemoveItem( "Link" )
' Put in the new link
backendDoc.CreateRichTextItem( "Link" )
Set rtDocLink = backendDoc.GetFirstItem( "Link" )
Call rtDocLink.AppendDocLink( newProjectDoc, "DocLink" )
Call backendDoc.Save( True, False )
' Close the UIdoc so the user can reopen it to see
? the new link. This is LotusScript limitation!