Assign One Rich Text Object to Another Rich Text Object

This section illustrates how to assign one Rich Text object to another. Unlike Text objects, where the object value can be easily set or reassigned, additional steps are required when working with Rich Text objects.

How It Works

One Rich Text object can be assigned to another Rich Text object by using the AppendRTItem method. To utilize this method, both objects must be defined as Rich Text. To assign one Rich Text object to another, call the AppendRTItem method and pass the name of the Rich Text object as a parameter. In the following example, rtItemB is copied into rtItemA.

This approach might be used to copy a Rich Text field from an existing document into a Rich Text field of a new document. This could also be used to copy a Rich Text field into the Body of an email message.

Implementation

The following illustrates how to assign Rich Text values. In this example, the Rich Text field (rtItemB) from a selected view document is appended to another Rich Text field (rtItemA). The result is sent via email to the person that clicked the button. To implement this solution, create an action button on a view and insert the following LotusScript code.

As a reminder, be sure to replace FIELD with the name of a Rich Text field that resides on the form. This field will be appended to the Rich Text field called "Body" and subsequently emailed to the person that clicks the button.

Sub Click(Source As Button)

 '--------------------------------------------
 ' Define the objects
 '--------------------------------------------
 Dim s As NotesSession
 Dim db As NotesDatabase
 Dim collection As NotesDocumentCollection
 Dim newdoc As NotesDocument
 Dim Person As NotesName
 Dim doc As NotesDocument
 Dim rtitemA As Variant
 Dim rtitemB As Variant
 Set s = New NotesSession
 Set db = s.CurrentDatabase
 Set collection = db.UnprocessedDocuments

 '-------------------------------------------------------
 ' Is a document selected?
 '-------------------------------------------------------
 If collection.count = 0 Then
 Msgbox("Please select a document.")
 Else
 '---------------------------------------------------
 ' Create email header
 '---------------------------------------------------
 Set newdoc = New NotesDocument(db)
 Set Person = New NotesName(s.UserName)
 newdoc.Form = "Memo"
 newdoc.SendTo = Person.Abbreviated
 newdoc.Subject = "This is the message subject"

 '---------------------------------------------------
 ' Copy itemB into itemA
 '---------------------------------------------------
 Set doc = collection.GetFirstDocument
 Set rtitemB = doc.GetFirstItem("FIELD")
 Set rtitemA = New NotesRichTextItem(newdoc, "Body")
 Call rtitemA.AppendRTItem(rtitemB)

 '---------------------------------------------------
 ' Send email
 '---------------------------------------------------
 newdoc.Send (False)
 Msgbox "Sample email sent"
 End If

End Sub


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

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

Security

Application Deployment and Maintenance

Troubleshooting

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

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net