Hi All,
I have a scenario where a user can open a form (stored in an SP2007 Form Library) via a URL that passes input parameters or they can open the form via the New button in a SharePoint Forms Library (no custom input parameters). When the user clicks the URL with parameters, everything works great, the URL parameters are passed in and my code in the Form_Submit event reads them and fills in the fields. But when they use the New button, try as I might, I cannot get the code to detect that the parameters are not present. I always get a 'System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary' error. I have tried e.InputParameters.ContainsKey, e.InputParameters.TryGetValue and I have tried just checking for null. In each case, I get the error when that line of code is executed (or even the line before that just declares a string variable, which is really strange?). I am new to InfoPath coding and coding in general so maybe I am missing something very obvious.
Here is the code I am currently using:
string jobnumber;
if (e.InputParameters.TryGetValue("jobnumber", out jobnumber))
{
XPathNavigator xnJobNumber = main.SelectSingleNode("/my:myFields/my:JobNumber", this.NamespaceManager);
xnJobNumber.SetValue(jobnumber);
}
Can anyone help?
Thanks!