<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Check if an Input Parameter Exists</title><link>https://www.infopathdev.com:443/forums/thread/68100.aspx</link><pubDate>Wed, 06 Jul 2011 03:03:18 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:68100</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/68100.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=68100</wfw:commentRss><description>&lt;p&gt;Two thinks you can do: 1. Iterate through all the items in the InputParameters collection, looking for the one you want.&amp;nbsp; This will also let you do a case-insensitive match on the key.&amp;nbsp; or 2. Place your lookup in a try-catch block.&lt;/p&gt;
&lt;p&gt;Either approach should work if the key is right, though I recommend the former.&lt;/p&gt;</description></item><item><title>Check if an Input Parameter Exists</title><link>https://www.infopathdev.com:443/forums/thread/68087.aspx</link><pubDate>Tue, 05 Jul 2011 20:21:09 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:68087</guid><dc:creator>louisekasemeier</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/68087.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=68087</wfw:commentRss><description>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 &amp;#39;System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary&amp;#39; 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:


&lt;br /&gt;&lt;br /&gt;string jobnumber;

&lt;br /&gt;if (e.InputParameters.TryGetValue(&amp;quot;jobnumber&amp;quot;, out jobnumber))

&lt;br /&gt; {

     
&lt;br /&gt;XPathNavigator xnJobNumber = main.SelectSingleNode(&amp;quot;/my:myFields/my:JobNumber&amp;quot;, this.NamespaceManager);

     &lt;br /&gt;xnJobNumber.SetValue(jobnumber);

&lt;br /&gt;}

&lt;br /&gt;&lt;br /&gt;
Can anyone help?

Thanks!</description></item></channel></rss>