Web LotusScript Agent - display results

I have a form that takes in two date values from the user. They click on a button that calls a lotusscript agent. Here is the code I have so far below:

Sub Initialize

Dim counter As Integer

Dim allDates As Variant

Dim concatResults As String

Dim dc As notesdocumentcollection

Dim lookupView As NotesView

Dim currDoc As NotesDocument

Set session = New NotesSession

Set db = session.CurrentDatabase

Set lookupView = db.GetView( "ABCD" )

counter = 0



Set doc = session.DocumentContext



If doc.FieldToSearch(0) = "Completed Date" Then

	Set lookupView = db.GetView( "ABCD" )

Else

	Set lookupView = db.GetView( "ABSD" )

End If



allDates = doc.GetItemValue("DatesExploded")



Forall v In allDates

	

	Set dc = lookupView.GetAllDocumentsByKey(v,True)

	If Not dc.Count = 0 Then

		Set doc = dc.GetFirstDocument

		

		While Not doc Is Nothing

			counter = counter + 1

			If doc.FieldToSearch(0) = "Completed Date" Then

				Set dTime = New NotesDateTime(Cstr(doc.CompletedDate(0)) )

				concatResults = Cstr(dTime.DateOnly) & Chr(9) & Chr(9) & Cstr(doc.RequestNum(0)) & Chr(9) & Chr(9) & Cstr(doc.NameOfService(0))

			Else

				

				Set dTime = New NotesDateTime(Cstr(doc.ScheduledDate(0)) )

				concatResults = Cstr(dTime.DateOnly) & Chr(9) & Chr(9) & Cstr(doc.RequestNum(0)) & Chr(9) & Chr(9) & Cstr(doc.NameOfService(0))

			End If

			Print "3"

			Print concatResults "<br>"

			'doc.dResults = currdoc.dResults + ";" + concatResults

			Set doc = dc.GetNextDocument(doc)

			Print "4"

		Wend

	End If

End Forall

Print "5"

If counter = 0 Then

	Print |<SCRIPT language="JavaScript">alert("No results were found for your search criteria.")</SCRIPT> 

|

End If

End Sub

As of now I print the results on a blank web page that automatically comes up after the button is clicked. I have a line of code commented out that is supposed to take the results and place it in a field on a form, but since it moves from the original form to a new page, I can’t use that field.

Does anybody have any ideas on how to display results? I’d like to display them in the same form, but if I have to display it opening up a new page, I’d like to do that with my database banner and CSS as well. Any thoughts?

Subject: You could try

improving the look of your output by including all the necessary HTML header and tags etc

Subject: RE: You could try

why not use Ajax, web agent write data to xml/json, javascript process return data and write into

Subject: Web LotusScript Agent - display results

The easiest way to get well-formatted returns is to open a form rather than an agent and use a WebQueryOpen agent to populate the form. That will allow you to use common subforms (for the page header/footer), and link easily to JavaScript files and CSS stylesheets and so on. Jake Howlett published a very neat way to do this over at codestore.net. You can feed the parameters as document fields or parse the querystring yourself in your WQO agent, then write the data to a rich text field.

The linked document is the final installment in a series of blogs describing the technique. There are a couple of otther useful links on the page, and the code in the download should be pretty much self-explanatory.