Introduction
In HCL Notes application development, there are situations where you may need to copy or replicate the complete content of one field into another field within the same document.
A common example is:
–Moving email body content
–Preserving original text before modification
–Creating audit or backup fields
–Replicating rich text content including attachments, images, and formatting
This article explains how to replicate the value of Field1 into Field2, including all rich text elements.
Requirement
Replicate the content of:
Field1 → Field2
Include:
Text
Formatting
Embedded objects
Attachments
Images
Implementation Approach :
-
Created two Rich Text fields in the sample form:
Field Name: Body1 Type: Rich Text and Editable Field Name: Body2 Type: Rich Text and Computed -
Created one action button and implemented the following LotusScript code to swap the complete content from Body1 to Body2.
Sub Click(Source As Button) Dim session As New NotesSession Dim ws As New NotesUIWorkspace Dim uiDoc As NotesUIDocument Dim doc As NotesDocument Dim db As NotesDatabase Dim unid As String Dim field1 As NotesRichTextItem Dim field2 As NotesRichTextItem Dim tempFieldName As String Dim tempField As NotesRichTextItem Set uiDoc = ws.CurrentDocument Set doc = uiDoc.Document On Error Resume Next 'Make sure we have a UNID and make sure validation passes Call uiDoc.Save On Error Goto 0 If Err <> 0 Then ' Validation error Err = 0 Exit Sub End If Set db = session.CurrentDatabase Set field1 = doc.GetFirstItem("Body1") Set field2 = doc.GetFirstItem("Body2") While doc.HasItem("Body2") Call doc.RemoveItem("Body2") Wend Set field2 = doc.CreateRichTextItem("Body2") Call field2.AppendRTItem(field1) Call doc.Save(True, False, True) Call doc.ReplaceItemValue("SaveOptions", "0") Call uiDoc.Reload Call uiDoc.Close(True) End Sub -
Previewed the form in the Notes Client and entered content into “Body1” field and saved the document.
-
Clicked the “Swap” button to successfully move the content from “Body1” to “Body2”.
Note : If you want to retain the existing content of Field2 and append the value from Field1, use the AppendRTItem method of the NotesRichTextItem class. In this case, do not delete or replace Field2 in the current document.
Reference : AppendRTItem (NotesRichTextItem - LotusScript®)
URL → AppendRTItem (NotesRichTextItem - LotusScript)
Best Practices
-Always save the document before manipulation
- Use Rich Text fields on both source and destination
- Avoid Computed-for-Display target fields
- Test with large attachments
- Validate user permissions
- Consider document locking scenarios
Practical Use Cases :
This approach can be extended to build powerful application features:
- Version history tracking
- Backup of original mail body
- Audit logging fields
- Approval workflow snapshots
- Automated archival fields
Conclusion
Duplicating rich text content inside the same Notes document is fully achievable using LotusScript. By using the AppendRTItem method, you can reliably transfer complete content including attachments and formatting between fields.
Disclaimer : Please note that the testing conducted is intended as an example to guide your implementation. We recommend working closely with your development team to adapt and integrate the solution into your specific production environment. Product Support is not available for customizing solutions to fit individual customer setups.