Add a Document, View, or Database Link to a Rich Text Field

Document, view, and database links offer a quick and easy way to reference database information. Links are often embedded in email messages and allow users to jump directly to a referenced item when clicked. This routine illustrates how to generate and embed a link in a Rich Text field.

How It Works

This is a built-in feature of the Lotus Notes client. Document, view, and database links are generated using the AppendDocLink method. Links can only be inserted in a Rich Text field or object.

Three parameters are associated with the AppendDocLink method. The first parameter passed to the AppendDocLink method must be a document, view, or database object. The second parameter is optional and displays in the bottom of the Lotus Notes client when the mouse hovers over the link. A third parameter can also be supplied that replaces the icon with a text link.




The following code illustrates how to attach both the document and database links. When the button is clicked, an email message is sent with the links to the current database and document. To implement this technique, create an action button and insert the following LotusScript code in the Programmer's pane.

Sub Click(Source As Button)

 Dim w As NotesUIWorkspace
 Dim s As NotesSession
 Dim db As NotesDatabase
 Dim uidoc As NotesUIDocument
 Dim doc As NotesDocument
 Dim newdoc As NotesDocument
 Dim rtitem as NotesRichTextItem
 Dim Person As NotesName
 Set w = New NotesUIWorkspace
 ' Set object values
 Set s = New NotesSession
 Set db = s.CurrentDatabase
 Set uidoc = w.CurrentDocument
 Set doc = uidoc.Document
 Set newdoc = New NotesDocument(db)
 Set Person = New NotesName(s.UserName)

 ' Create the email and richtext object
 newdoc.Form = "Memo"
 newdoc.SendTo = Person.Abbreviated
 newdoc.Subject = "Sample document and database link"
 Set rtitem = New NotesRichTextItem(newdoc, "Body")

 ' Append the document link (doc)
 Call rtitem.AddNewLine(1)
 Call rtitem.AppendDocLink(doc, db.Title)
 Call rtitem.AppendText(" <--- Click to open document.")

 ' Append the database link (db)
 Call rtitem.AddNewLine(1)
 Call rtitem.AppendDocLink(db, db.Title)
 Call rtitem.AppendText(" <--- Click to open database.")

 ' Send message
 newdoc.Send (False)
 Msgbox "Sample email sent"

End Sub



A default view must be associated with the database in order to implement this solution. Although there are no specific references to any view in the LotusScript code, a default view association must exist in order to generate the document link. If a default view has not been established, an error message similar to Figure 13.27 will display.

Figure 13.27. No default view specified error message

To assign a default view, select and open the view in the Domino Designer client. Select the Design > View Properties menu option to display the properties dialog. Switch to tab 2 and select the option Default when database is first opened (see Figure 13.28).

Figure 13.28. "Default when database is first opened" setting in the View properties dialog

Save and close the view.


If users are unable to open the document or database when clicked, you may need to have them create a connection document in order to correct the error "Unable to find path to server." See Chapter 21, "Troubleshooting," for additional information on troubleshooting and how to create a connection document. If the user is still unable to access the document or database, the ACL may need to be updated to grant access to the database (see Chapter 19, "Security," for additional information on database security settings).

An Introduction to the Lotus Domino Tool Suite

Getting Started with Designer

Navigating the Domino Designer Workspace

Domino Design Elements

An Introduction to Formula Language

An Introduction to LotusScript

Fundamentals of a Notes Application

Calendar Applications

Collaborative Applications

Reference Library Applications

Workflow Applications

Web Applications

Design Enhancements Using LotusScript

Design Enhancements Using Formula Language

View Enhancements

Sample Agents

Miscellaneous Enhancements and Tips for Domino Databases

Data Management


Application Deployment and Maintenance


Appendix A. Online Project Files and Sample Applications

Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?

Lotus Notes Developer's Toolbox(c) Tips for Rapid and Successful Deployment
Lotus Notes Developers Toolbox: Tips for Rapid and Successful Deployment
ISBN: 0132214482
EAN: 2147483647
Year: N/A
Pages: 293
Authors: Mark Elliott © 2008-2020.
If you may any questions please contact us: