Help - moving attachment from one field to another

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)

End Sub

Subject: NotesRichTextItem Updates in Back-End

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))

See http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/e1dbd5446138717d8525721e004c61ff?OpenDocument for the risk of getting the cached back-end document if you omit “Delete uidoc”.

Hope this Helps

Paul

Subject: Thanks Paul

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?

Subject: Exactly

But getting the document again without any reference to the front-end document in memory, so we’re certain to get the up-to-date version.