Q

How do I pass attachments from one form to another using LS?

How do I pass attachments from one form to another using LotusScript? I have script (see below), which works well for all number, date and text fields, but will not work for Rich Text. Basically I have a data input form on a page on the frameset, which is used to create documents in the background. Below is a shorten script that generates "Object Variable Not Set" on line "Call docT.CopyItem( tattach, 'attach' )".
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
Your problem lies in you mixing background and foreground methods.

CopyItem is a LotusScript method for copying an item of the type NotesItem. A NotesItem is only available on a background document.

So your 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

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter
SearchContentManagement
Close