Opening a form w/JS and prefilling it with values

Hi,

I have a Welcome form which offers a list of reports for the user to choose from, and a Submit button. The Submit button calls a LS agent using @Command([ToolsRunMacro]; “MyAgent”). MyAgent contains the following code:

=========================

Sub Initialize

Dim session_this As New NotesSession

Dim doc_this As NotesDocument

Dim str_print As String



Set doc_this = session_this.DocumentContext



str_print = "http://myserver.com/mydatabase.nsf/ReportForm?OpenForm"



Print {<script type="text/javascript">window.location="} + str_print + {";window.document.forms[0].ReportType.value = "} & Cstr(doc_this.ReportType(0)) & {";window.document.forms[0].UserReport.value = "} & Cstr(doc_this.UserReport(0)) & {";document.location.reload(true);</script>} 

End Sub

==========================

What I want to do is (1) open the form in my browser, (2) fill the ReportType and UserReport fields in with values obtained from the Welcome form, and (3) load an embedded view on the ReportForm with the value of UserReport (ReportForm currently has an embedded view with a selection by formula, and the formula is “UserReports”). When I try the code above, the ReportForm loads, but the ReportType and UserReport fields are not loaded, and so the form opens up as blank.

How can I open this form, prefill it with my field values, and do a document refresh or whatever else is necessary to load my embedded view with my field values? Any help is appreciated on this one.

Thanks in advance,

Sam

Subject: Use a Query_String to fill…

str_print = "http://myserver.com/mydatabase.nsf/ReportForm?OpenForm"	str_print = str_print + {&rt=} + doc_this.ReportType(0)

str_print = str_print + {&ur=} + doc_this.UserReport(0)

Print {<script type="text/javascript">window.location="} + str_print + {";</script>} 

Then get the value of Query_String in the Report Form.

Subject: RE: Use a Query_String to fill…

Bill,

Thanks for the reply. I should have mentioned this before, but I had already tried a solution with URL parameters in the “?OpenForm” call, but the problem with that method was the categories in my embedded view would not expand or collapse, and the sorting features of the view would not work. I believe this is because these functions work by adding something similar to “&Start=1&Count=1000&Collapse=1&Seq=1” to the end of the URL, and this overwrites the field parameters my form needs.

Is there any way to change the default behavior of a view, so that it retains the field parameters when you click on a twistie instead of overwriting them?

Thanks again,

Sam