WebQueryOpen to populate items on a new doc

Hi all,

Is it possible to run an agent like the following on a WQO and have the data populate properly. The key to success in this is getting the first item from the looked up document and having it attach to current document being composed… the other fields I could compute on the form easy enough, but I am not sure how to compute the attachment item. I hope this makes sense.

Here is my (not working - currently just presents a 404 error) code:

Dim session As New NotesSession

Dim curdb As NotesDatabase

Dim curdoc As NotesDocument



Dim employees As notesview



Dim signature As NotesItem



Dim employee As notesdocument



Dim key As Variant

Dim server As String

	

Set curdb = session.CurrentDatabase

Set curdoc = session.DocumentContext



server = curdb.Server

	

Set employees = curdb.GetView ("admvSTF")

	

key = session.UserName



Set employee = employees.getdocumentbykey(key)



If employee Is Nothing Then

	Exit Sub

Else

	

	Set signature = employee.GetFirstItem( "admEmploySign" )

	Call signature.CopyItemToDocument( curdoc, "" )

	curdoc.csnStaffPerson = key

	curdoc.csnStaffTeam = employee.admEmployTeam(0)

	curdoc.csnStaffID = employee.admEmployID(0)

	

End If

Subject: WebQueryOpen to populate items on a new doc.

On the web, session.UserName returns the server name. Set the agent to run as web user and use session.EffectiveUserName. (You may need to run it through a NotesName object to get the abbreviated or common version, depending on what’s in the view.)

Subject: RE: WebQueryOpen to populate items on a new doc.

Hi Stan,

Thanks for your response… I will be sure to implement your recommendation. Unfortunately, in my testing I am using a hardcoded value that matches the only document in the view. the view works for similar code run in the client but on the web I don’t seem to get a handle on the document and then get the values from it I need.

Any other suggestions?