Dim s As New notessession Dim db As notesdatabase Dim docT As notesdocument Dim uiw As New notesuiworkspace Dim uidoc As notesuidocument Dim tcategory As String Dim tattach As NotesItem Set db = s.currentdatabase Set uidoc = uiw.currentdocument Call uidoc.refresh tcategory = uidoc.fieldgettext ("tcategory") Set tattach = docT.GetFirstItem ( "tattach" ) Set docT = db.createdocument With docT .form = "todo" .category = tcategory Call docT.CopyItem( tattach, "attach" ) End With
CopyItem is a LotusScript method for copying an item of the type NotesItem. A NotesItem is only available on a background document.
Call docT.CopyItem( tattach, "attach" ) is OK except for the bit where it says
tattach. Tattach is not a reference to a NotesItem, it is a field on the foreground document -- the UIdoc.
What you need to do is something like this:
Call uidoc.Save Dim backDoc As Notesdocument Set backDoc = uidoc.Document Dim tattachItem As NotesItem Set tattachItem = backDoc. GetFirstItem("tattach") Call docT.CopyItem(tattachItem, "attach" )I believe that this would do the trick.
Do you have comments on this Ask the Expert Q&A? Let us know.
Dig Deeper on LotusScript
Related Q&A from Jens Bruntt
Learn about an add-on Domino developers can use to programmatically edit rich-text field tables from within the Lotus Notes client. Continue Reading
Web Development expert Jens Bruntt outlines three potential issues to consider when troubleshooting Lotus Notes Domino tabbed table problems. Continue Reading