Create new doc from web via agent

Hi,this is my problem. I have a web-db, where users can see a list of offered services with available containers. They can click on one service, which opens a new document (with reader field) where they can enter the amount of containers the like to book. To get the right amount of already booked containers (from all other clients also) I need a view where all booked containers are visible, and due to the reader field that doesn’t work with that form. Therefor I thought I create an agent on the booking-form, which creates a new document in the backround (without reader field), which I could use in a view for counting. This is the script of the agent

Dim ws As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim parent As NotesDocument

Set db = session.CurrentDatabase

Set view = db.GetView("c1")

view.AutoUpdate = False

Set parent = view.GetFirstDocument	



While Not (parent Is Nothing)		

	Set doc = db.CreateDocument

doc.col_service = parent.GetItemValue("bu_service")				doc.Form = "collector"	

	Call doc.ComputeWithForm( True, True )	

	Call doc.Save(True, False)

	parent.collect = "0"

	Call parent.Save(True,False)

	Set parent = view.GetNextDocument(parent)		

Wend

At the moment it has only one field for testing. The agent works fine if I run it manually from “Action”. But when I enter this agent either in “WebQuerySave” (ToolsRunMacro), or after my “@Commanc(FileSave)” nothing happens.

So I don’t know now, if this agent is not running at all or if it is not working from when started from web. Can maybe someone give me a hint on this. Thanks

Oliver

Subject: create new doc from web via agent

There is no ui class in WEB.To get handle of the current document in web you have to use documentcontext property of notessession.Even you can use Print statements to print values in web browser.

Subject: RE: create new doc from web via agent

Wow,changed my agent to

Dim session As New NotesSession

Set session = New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim parent As NotesDocument

Set db = session.CurrentDatabase

Set parent = session.DocumentContext



Set doc = db.CreateDocument

		'Feld wird Wert gefüllt	

doc.col_service = parent.bu_service(0)

doc.Form = "collector"	

Call doc.ComputeWithForm( True, True )	

Call doc.Save(True, False)

parent.collect = "0"

Call parent.Save(True,False)

and it does exactly what i was looking for. Thanks a lot.