<?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: Get Value from currently selected node</title><link>https://www.infopathdev.com:443/forums/thread/36583.aspx</link><pubDate>Mon, 05 Jan 2009 16:30:29 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:36583</guid><dc:creator>Patrick</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/36583.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=36583</wfw:commentRss><description>&lt;p&gt;Thanks Jimmy!&amp;nbsp; Worked great :)&lt;/p&gt;</description></item><item><title>Re: Get Value from currently selected node</title><link>https://www.infopathdev.com:443/forums/thread/36519.aspx</link><pubDate>Sat, 03 Jan 2009 03:06:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:36519</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/36519.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=36519</wfw:commentRss><description>&lt;p&gt;Set the default value of the destination field to the following XPath formula&amp;nbsp;(making the appropriate modifications),&amp;nbsp;&lt;em&gt;but don&amp;#39;t&lt;/em&gt;&amp;nbsp;check &amp;quot;Update this value when the result of the formula is recalculated.&amp;quot;&amp;nbsp; This will set that destination node to the appropriate value when the form loads.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;/my:myFields/my:group1/my:group2&lt;/strong&gt;&lt;/em&gt;[position() = xdXDocument:GetNamedNodeProperty(&lt;em&gt;&lt;strong&gt;/my:myFields/my:group1&lt;/strong&gt;&lt;/em&gt;, &amp;quot;&lt;em&gt;&lt;strong&gt;CTRL1_5&lt;/strong&gt;&lt;/em&gt;&amp;quot;, 1)]/&lt;em&gt;&lt;strong&gt;my:field2&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Here &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;/my:myFields/my:group1/my:group2 is the repeating node&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;/my:myFields/my:group1 is the node that contains the repeating node&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;CTRL1_5 is the value of the&amp;nbsp;ViewContext property of the repeating table (you can find this value by viewing the repeating table&amp;#39;s properties and looking at the Advanced tab)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;my:field2 is the child of my:group2 that you want to copy to the destination field&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Then adding&amp;nbsp;a Context Change event to your form with code like the following should take care of the rest:&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; FormEvents_ContextChanged(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; sender, &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;ContextChangedEventArgs&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (e.ChangeType == &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;ContextNode&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; repeatingNode = e.Context.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;ancestor-or-self::&lt;em&gt;&lt;strong&gt;my:group2&lt;/strong&gt;&lt;/em&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager);&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (repeatingNode != &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#0000ff"&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; &lt;/font&gt;XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; destinationNode = repeatingNode.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&lt;strong&gt;&lt;em&gt;/my:myFields/my:outsideField&lt;/em&gt;&lt;/strong&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager);&lt;br /&gt;&lt;font color="#0000ff"&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; &lt;/font&gt;destinationNode.SetValue(repeatingNode.SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&lt;strong&gt;&lt;em&gt;my:field2&lt;/em&gt;&lt;/strong&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).Value);&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;}&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;}&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;Again, my:group2 is the repeating node, /my:myFields/my:outsideField is the destination node, and my:field2 is the field whose value I want to copy.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;That should work for most situations.&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Get Value from currently selected node</title><link>https://www.infopathdev.com:443/forums/thread/36514.aspx</link><pubDate>Fri, 02 Jan 2009 19:34:07 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:36514</guid><dc:creator>Patrick</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/36514.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=36514</wfw:commentRss><description>&lt;p&gt;I hope this is a quick and easy one...&lt;/p&gt;&lt;p&gt;I&amp;#39;m using InfoPath 2007 and C# code.&amp;nbsp;&lt;/p&gt;&lt;p&gt;I have a master/detail relationship and I want a value from the &amp;quot;Master&amp;quot; table to populate in a field that is not part of the repeating group that the master/detail is a part of.&amp;nbsp; I am trying to get a value from a single field in the repeating table to the destination field.&amp;nbsp; The value would change whenever the user selects a new row.&amp;nbsp; The destination field is just a text box (non-repeating). &lt;/p&gt;&lt;p&gt;So basically I want to take a value from a field in the currently selected row of a repeating table and copy it to a non-repeating field, and have it change if the user selects a different row.&amp;nbsp; How do I reference the currently selected row in a table?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br /&gt;Thanks!&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>