In the following example, an InfoPath form template is opened from either the command line or URL using the following syntax.
Command-line:
infopath.exe "C:\User Forms\DeptReport.xsn" /InputParameters "Dept=Accounting"
URL:
http://server/sites/team/forms/DeptReport.xsn?Dept=Accounting
The InputParameters property is used from a Loading event handler to set the Department field value to the value "Accounting" which was passed using the /InputParameters command-line option or URL input parameter.
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
string vDept = e.InputParameters["Dept"];
XPathNavigator myNav = CreateNavigator();
myNav.SelectSingleNode("/my:myFields/my:Department",
NamespaceManager).SetValue(vDept);
}
Public Sub FormEvents_Loading(ByVal sender As Object, _
ByVal e As LoadingEventArgs)
Dim vDept As String = e.InputParameters("Dept")
Dim myNav As XPathNavigator = CreateNavigator()
myNav.SelectSingleNode("/my:myFields/my:Department",
NamespaceManager).SetValue(vDept)
End Sub