I’m attempting to move attachments from one rich text field to another within a document via a button click. I’ve actually got the code working, but there’s a few small problem. First my code only works if the document is opened in read mode. If you’re in edit mode the code doesn’t work. Secondly even if you’re in read mode when you click the button you don’t actually see anything change. The attachments appear to still be in the previous field until you close the document out and reopen it. Can anyone provide suggestions? My code is below:
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rt_to As NotesRichTextItem
Dim rt_from As NotesRichTextItem
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Set rt_from = doc.GetFirstItem( "Attach" )
Set rt_to = doc.GetFirstItem("PrevRevAttach")
Call rt_to.AppendRTItem(rt_from)
Call doc.replaceitemvalue("Attach","")
Call doc.Save(False,True)
If you look at the NotesUIDocument.Reload method help, this documents that unfortunately rich text items modified in the back-end do not appear in the front-end until the document has been closed and re-opened.
Your best option is to add at the end:
Dim db as NotesDatabase
Dim parentID as String
Set db = doc.ParentDatabase
parentID = doc.UniversalID
call uidoc.Close(True)
Delete uidoc
Set uidoc = ws.EditDocument(False, db.GetDocumentByUNID(parentID))
I’m still kind of new to the LS world. By looking at the code you posted, am I right in thinking that it’s basically closing the document and then reopening it?