<?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: Retrieve SharePoint Form ID in code?</title><link>https://www.infopathdev.com:443/forums/thread/38977.aspx</link><pubDate>Thu, 26 Feb 2009 15:15:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38977</guid><dc:creator>burtikus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38977.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=38977</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/infopathdev/images/icon-quote.gif"&gt; &lt;strong&gt;Hilary Stoupa:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/p&gt;&lt;p&gt;I overlooked your variable &amp;#39;xnMyForm&amp;#39; -- I bet that is pointed to your Main Data Source, and, of course, the XPath you are using won&amp;#39;t be valid against that.... you&amp;#39;d need something along the lines of:&lt;/p&gt;
&lt;blockquote&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; RFCID = &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.DataSources[&lt;/font&gt;&lt;font size="2" color="#a31515"&gt;&lt;font size="2" color="#a31515"&gt;&amp;quot;MyDataSource&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;].CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font size="2" color="#a31515"&gt;&lt;font size="2" color="#a31515"&gt;&amp;quot;/dfs:myFields/dfs:dataFields/dfs:Request_For_Change/@ID&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;font size="2"&gt;NamespaceManager&lt;/font&gt;).Value; &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Well as soon as I read this, it&amp;#39;s like a lightbulb went off over my head.&amp;nbsp; I was just sure you were right about that.&amp;nbsp; But, it didn&amp;#39;t affect the behavior at all. :(&lt;/p&gt;&lt;p&gt;&amp;nbsp;I still get the error: &lt;/p&gt;&lt;p&gt;System.NullReferenceException was unhandled by user code&lt;br /&gt;&amp;nbsp; Message=&amp;quot;Object reference not set to an instance of an object.&amp;quot;&lt;br /&gt;&amp;nbsp; Source=&amp;quot;RFC_Master&amp;quot;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/infopathdev/images/icon-quote.gif"&gt; &lt;strong&gt;Hilary Stoupa:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;If you just drag the main repeating group from your secondary data source onto the form somewhere and preview the form, you get data?&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;So i tried this, and the answer, surprisingly to me, was no, I did not.&amp;nbsp; So I went back to modify the query data source, and noticed that there was a check box that said &amp;quot;Include data for the active form only&amp;quot; that was checked.&amp;nbsp; I unchecked this, just to see what happened, and now all of a sudden I&amp;#39;m retrieving the most recent ID from the library - but it&amp;#39;s NOT the one associated with this form, as it exists before this form is submitted to the library. What I&amp;#39;m guessing is going on is that it actually is retrieving all of the form ids, and select single node just displays the one?&amp;nbsp; But I could be way wrong about that too.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This does, sort of solve my problem though, I think.&amp;nbsp; Now if in my initial submit code I query that data connection after the form is submitted the first time, the field does contain the latest form id and I can populate my data source and resubmit.&amp;nbsp; But I don&amp;#39;t think it&amp;#39;s working in the sense I want it to, as I could see at least a theoretically possible situation where two forms get submitted at exactly the same moment... but maybe that&amp;#39;s just picking nits.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Thank you so much for your help, Hilary.&amp;nbsp; This has been driving me NUTS, and I don&amp;#39;t know that I ever would have figured out that different navigator thing.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Tim&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Retrieve SharePoint Form ID in code?</title><link>https://www.infopathdev.com:443/forums/thread/38947.aspx</link><pubDate>Thu, 26 Feb 2009 00:57:09 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38947</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38947.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=38947</wfw:commentRss><description>&lt;p&gt;I overlooked your variable &amp;#39;xnMyForm&amp;#39; -- I bet that is pointed to your Main Data Source, and, of course, the XPath you are using won&amp;#39;t be valid against that.... you&amp;#39;d need something along the lines of:&lt;/p&gt;
&lt;blockquote&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; RFCID = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.DataSources[&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;MyDataSource&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;].CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;/dfs:myFields/dfs:dataFields/dfs:Request_For_Change/@ID&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;font size="2"&gt;NamespaceManager&lt;/font&gt;).Value; &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;With&amp;nbsp;&lt;font color="#a31515"&gt;MyDataSource&lt;/font&gt; replaced with the name of your secondary data source.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;If you just drag the main repeating group from your secondary data source onto the form somewhere and preview the form, you get data?&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Retrieve SharePoint Form ID in code?</title><link>https://www.infopathdev.com:443/forums/thread/38911.aspx</link><pubDate>Wed, 25 Feb 2009 14:37:29 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38911</guid><dc:creator>burtikus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38911.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=38911</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;The XPath I just copied from the data source, so I&amp;#39;m assuming that&amp;#39;s right.&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The line that causes the error is &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string RFCID = xnMyForm.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/dfs:Request_For_Change/@ID&amp;quot;, ns).Value; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I&amp;#39;m pretty new at InfoPath and SharePoint, but I do basically agree that I&amp;#39;m likely not getting results from the query.&amp;nbsp; Trying to access the contents of that data source through the UI doesn&amp;#39;t work either. I even tried creating a button that I could click on the form to execute the query and then set a field&amp;#39;s value to the result.&amp;nbsp; Nothing.&lt;/p&gt;&lt;p&gt;&amp;nbsp;The odd thing is that when I setup the secondary data source, it finds the ID field just fine, and when I create a view in Sharepoint to show the ID field it is there.&amp;nbsp; But I cannot seem to retrieve the field at all.&amp;nbsp; I&amp;#39;m kinda banging my head on this one as it seems like I must have just done something wrong, but I cannot figure out just what that was. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Retrieve SharePoint Form ID in code?</title><link>https://www.infopathdev.com:443/forums/thread/38884.aspx</link><pubDate>Wed, 25 Feb 2009 02:18:47 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38884</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38884.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=38884</wfw:commentRss><description>&lt;p&gt;Hi, and welcome!&lt;/p&gt;
&lt;p&gt;Offhand, I&amp;#39;d guess your Object ref error would be related to a bad Xpath in your code, or you are not getting results from your query. What line causes the error? Can you put a breakpoint in your code and run it in debug?&lt;/p&gt;</description></item><item><title>Retrieve SharePoint Form ID in code?</title><link>https://www.infopathdev.com:443/forums/thread/38857.aspx</link><pubDate>Tue, 24 Feb 2009 19:14:47 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38857</guid><dc:creator>burtikus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38857.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=38857</wfw:commentRss><description>&lt;p&gt;Hi all,&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I have an InfoPath form that is being submitted to a SharePoint form library.&amp;nbsp; After the form has been submitted, I would like to retrieve the ID field from the form library and store it in the form&amp;#39;s data source.&amp;nbsp; I can do this in many different ways, but so far nothing I&amp;#39;ve tried is working.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I have set up a secondary data connection to the form library and set it to have only one column, namely the ID field.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;So when I try something like:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataConnection SubmitConnection = this.DataConnections[&amp;quot;Submit to Form Library&amp;quot;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SubmitConnection.Execute();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(NewStatus == &amp;quot;New&amp;quot;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //query for Form ID, set ChangeRequestNumber to FormID, and resubmit&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataConnection QueryConnection = this.DataConnections[&amp;quot;ChangeManagementID&amp;quot;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QueryConnection.Execute();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string RFCID = xnMyForm.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/dfs:Request_For_Change/@ID&amp;quot;, ns).Value;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xnMyForm.SelectSingleNode(&amp;quot;/my:ChangeRequest/my:HeaderInfo/my:ChangeRequestNumber&amp;quot;, ns)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .SetValue(RFCID);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SubmitConnection.Execute();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I get the object reference not set to an instance of an object error.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Alternately, since this particular form will be opened and closed about 10 times during it&amp;#39;s life and I just want to get the information there EVENTUALLY, I tried setting the form options -&amp;gt; open rules to set a field to a value, and set my ChangeManagementID field equal to @ID from the secondary datasource.&amp;nbsp; That does not work either, but I don&amp;#39;t get an error either.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Any suggestions?&amp;nbsp; I have considered trying to hack this on the first submit by trying to calculate max(id) + 1, but that does not seem like a good solution.&amp;nbsp; I could also maintain my own ID field in the form library and populate with max(id) + 1, but that&amp;#39;s far from the best solution either.&amp;nbsp; What I really want here is the actual sharepoint form library id, but I&amp;#39;m having a hard time finding it.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks so much for any help!&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Tim&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>