Hello,
I have some LotusScript code that executes in the Postopen event of a new document. Its purpose is to copy into this new document any attachments that are in the document’s parent document. I got the original code from this forum, and it works perfectly when using a 6.5.3 client. Unfortunately 6.5.4 has just been rolled out and the code has ceased to work. What is happening now is that the ‘picture’ for the attachment is in the new document, but when you click on it, the message ‘item not found’ is displayed. I have used the LotusScript debugger and it appears that no items are being copied into doctemp and the HASEMBEDDED flag = False.
The code is listed below:
Sub Postopen(Source As Notesuidocument)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doctemp As NotesDocument
Dim docsource As NotesDocument
Dim parentUnid As String
'routine to copy file attachments into the current document from its parent doc
'only do it if the request document is new
If Not Source.IsNewDoc Then
Exit Sub
End If
'attach to back-end document and get docid of its parent
Set doc = Source.Document
parentUnid = doc.ParentDocid(0)
'using this docid copy all the items from the parent document to a temporary document
Set db = session.CurrentDatabase
Set docsource = db.GetDocumentByUNID(parentUnid)
Set doctemp = db.CreateDocument
Call docsource.CopyAllItems(doctemp)
'delete all items from this temporary document except any file attachments
Forall item In doctemp.Items
If Not (Ucase(item.NAME) = "$FILE") Then
doctemp.RemoveItem(item.NAME)
End If
End Forall
'copy the file attachments to the current document
Call doctemp.CopyAllitems(doc)
End Sub
I would be grateful for any suggestions people may have or any ideas that might point me in the right direction
Thanks