Sub Initialize
'connect to current db
Dim session As New NotesSession
Set db = session.CurrentDatabase
'get view Attach and get first document
Set memoview = db.GetView ( “Attach” )
Set memodoc = memoview.GetFirstDocument
Set memoid = memodoc.GetFirstItem ( “ID” )
'get view Order and get first document
Set dominoview = db.GetView ( “Order” )
Set dominodoc = dominoview.GetFirstDocument
Set dominoid = dominodoc.GetFirstItem ( “ID” )
If memoid.Values ( 0 ) = dominoid.Values ( 0 ) Then
Msgbox ( “You’re doing great!” )
Set rtitem = memodoc.GetFirstItem ( “Body” )
If ( rtitem.Type = RICHTEXT ) Then
Call rtitem.CopyItem ( dominodoc, "FileAttach" ) ***** this line here fails
End If
Call dominodoc.Save ( False, False )
memodoc.Processed = "Yes"
Call memodoc.Save ( False, True )
Else
Set dominodoc = dominoview.GetNextDocument ( dominodoc )
End If
Set memodoc = memoview.GetNextDocument ( memodoc )
Any help appreciated - thank you!
Subject: Please debug lotusscript - copy attachment from one doc to another
You should be doing EITHER Set rtitem=memodoc.CopyItem(
OR
Call dominodoc.CopyItem(
not
Call rtitem.CopyItem
Subject: Did I do it right? It’s not working…
I did do a version with CopyItemToDocument and it copied the rich text field over but it didn’t appear as an icon.
I need to copy an attachment from doc a to doc b - both docs are in the same database. Doc a is an email with the attachment in the Body field. Doc B is a form I created that has a rich text field called FileAttach.
Thanks!
'if IDs match
If memoid.Values ( 0 ) = dominoid.Values ( 0 ) Then
'get rich text item on email (memodoc)
Set rtitem = memodoc.GetFirstItem ( “Body” )
If ( rtitem.Type = RICHTEXT ) Then
Call dominodoc.CopyItem ( rtitem(0), “FileAttach” ) *****FAILS HERE
memodoc.Processed = “Yes”
Call memodoc.Save ( False, True )
Call dominodoc.Save ( False, False )
End If
Else
Set dominodoc = dominoview.GetNextDocument ( dominodoc )
End If
Set memodoc = memoview.GetNextDocument ( memodoc )
Subject: RE: Did I do it right? It’s not working…
Y dont u try this?Call rtitemA.AppendRTItem( rtitemB )
Subject: Please debug lotusscript - copy attachment from one doc to another
Rich Text is tricky to copy. Try this method I’ve found that it works if you do not already have a value in the body field on the memo.Dim rtItemA as variant
set rtItemA = dominodoc.Getfirstitem(“FileAttach”)
call memodoc.removeitem(“Body”)
Set rtItemB = New NotesRichTextItem(memodoc, “Body”)
Call rtitemB.appendrtitem(rtItemA)
Subject: RE: Please debug lotusscript - copy attachment from one doc to another
Still not working…
Dim session As New NotesSession
Set db = session.CurrentDatabase
Set memoview = db.GetView ( "Attach" )
Set memodoc = memoview.GetFirstDocument
Set memoid = memodoc.GetFirstItem ( "ID" )
Set dominoview = db.GetView ( "Order" )
Set dominodoc = dominoview.GetFirstDocument
Set dominoid = dominodoc.GetFirstItem ( "ID" )
While Not ( memodoc Is Nothing )
If memoid.Values ( 0 ) = dominoid.Values ( 0 ) Then
Set rtitemmemo = memodoc.GetFirstItem ( "Body " )
Set rtitemdomino = New NotesRichTextItem ( dominodoc, "FileAttach" )
Call rtitemdomino.AppendRTItem ( rtitemmemo )
dominodoc.Processed = "Yes"
Call dominodoc.Save ( False, True )
memodoc.Processed = "Yes"
Call memodoc.Save ( False, True )
'Set rtitem = New NotesRichTextItem ( memodoc, "Body" )
'Call rtitem.CopyItemToDocument ( dominodoc, "FileAttach" )
Else
Set dominodoc = dominoview.GetNextDocument ( dominodoc )
End If
Set memodoc = memoview.GetNextDocument ( memodoc )
Wend