Wednesday, January 20, 2010

Lotusscript code to transfer contents of one richtext field to an other

Put the following code in a button on a form and ensure that you map the relevant richtext fields in this code

    Dim  s As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim tdoc As NotesDocument
    Dim vw As NotesView   
    Dim currItem As Variant   
    Dim targetitem As Variant
    Dim seconditem As Variant   
    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
   
    Set db=s.CurrentDatabase
    Set uidoc=ws.CurrentDocument
    Set doc=uidoc.Document
   
    Set vw=db.GetView("DHTMLDemo")
    Set tdoc=vw.GetFirstDocument
    If(doc.HasItem("SourceRT")) Then
        Set currItem=doc.GetFirstItem("SourceRT")
    Else
        Set currItem=doc.CreateRichTextItem("SourceRT")
    End If
   
    If(doc.HasItem("TestRT")) Then
        Set seconditem=doc.GetFirstItem("TestRT")
    Else
        Set seconditem=doc.CreateRichTextItem("TestRT")
    End If
   
    Call seconditem.AppendRTItem(currItem)   
    Call doc.Save(True,False)
    Call doc.ReplaceItemValue("SaveOptions","0")
    Call uidoc.Close
    set uidoc=ws.editdocument(true,doc)

'on the post open event of the form, put the following code
if not source.isnewdoc then
    call source.document.SaveOptions="1"
end if

No comments:

Post a Comment