<?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>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/21989.aspx</link><pubDate>Thu, 26 Jul 2007 05:14:08 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:21989</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/21989.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=21989</wfw:commentRss><description>&lt;p&gt;Hi Ihmunro and welcome to our forum!&lt;/p&gt;&lt;p&gt;Are you asking how to add code to an InfoPath form? &lt;/p&gt;</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/21987.aspx</link><pubDate>Wed, 25 Jul 2007 22:06:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:21987</guid><dc:creator>ihmunro</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/21987.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=21987</wfw:commentRss><description>&lt;p&gt;Hi&lt;/p&gt;&lt;p&gt;&amp;nbsp;Doe this just cop one field 61 times so that you end up with Field 1, Field 2 etc&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;If so, this is what I need - I am not sure how to start the code.&lt;/p&gt;</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/2274.aspx</link><pubDate>Wed, 03 May 2006 19:49:53 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2274</guid><dc:creator>spudy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2274.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2274</wfw:commentRss><description>Thanks for your response Shanthi.&lt;br /&gt;&lt;br /&gt;I discovered the problem related to the incorrect function being called. You weere right concerning the return - without it it works!&lt;br /&gt;&lt;br /&gt;Thanks again, Spudy</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/2273.aspx</link><pubDate>Mon, 01 May 2006 06:27:50 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2273</guid><dc:creator>Shanthi Reddy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2273.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2273</wfw:commentRss><description>Hello Paul,&lt;br /&gt;   With regards to your first objective, you can get the answer by doing .childNodes on the IXMLDomNode. This will give you an IXMLDomNodeList. You can do a .length on this to find out the number of children of the row node&lt;br /&gt;&lt;br /&gt;About why the loop is not working correctly, did you debug to see where its actually failing when you have a loop. You could put a try/catch block and do an alert on the message. &lt;br /&gt;&lt;br /&gt;But I think you definitely should not have return(i) after the loop. What happens if you remove that? Are you still getting an added empty row?</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/2272.aspx</link><pubDate>Thu, 27 Apr 2006 10:00:48 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2272</guid><dc:creator>spudy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2272.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2272</wfw:commentRss><description>Perhaps if I describe what it is I am trying to do again.&lt;br /&gt;&lt;br /&gt;I have 61 fields (named fielda1, fielda2, etc to fielda61) that I have used to collect data in a view. I have a cloned node of 61 fields (named field1, field2 etc.. to field61) and I wish to copy the collected data into this cloned node.&lt;br /&gt;&lt;br /&gt;So I need to copy fielda1 to field1, then increment by 1, then copy fielda2 to field2 through until fielda61 to field61 is copied.&lt;br /&gt;&lt;br /&gt;Only once this loop until has copied all 61 fields, only then does the cloned node have all of it's information, and only then does it need to be appended to the parent.&lt;br /&gt;&lt;br /&gt;So my first objective and question here is how to count how many fields(cells?) exist in the cloned node(row?). &lt;br /&gt;&lt;br /&gt;The number is currently 61 but may change in the future. But for the purposes of testing the loop I have hard-coded 61. The example below still does not work:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;{&lt;br /&gt;// get a reference to the node to clone&lt;br /&gt;var row = XDocument.DOM.selectSingleNode("//my:RoomData/my:RoomDetail") ;&lt;br /&gt;row = row.cloneNode(true) ;&lt;br /&gt;//start counter at 1&lt;br /&gt;var i = 1;&lt;br /&gt;while ( i &amp;lt;= 61 )&lt;br /&gt;   {&lt;br /&gt;	var fieldTitle = "my:field" + i;&lt;br /&gt;	var fieldaTitle = "//my:fielda" + i;&lt;br /&gt;	row.selectSingleNode(fieldTitle).text = XDocument.DOM.selectSingleNode(fieldaTitle).nodeTypedValue;&lt;br /&gt;    i++;&lt;br /&gt;   }&lt;br /&gt;   return(i);&lt;br /&gt;var parent = XDocument.DOM.selectSingleNode("//my:RoomData") ;&lt;br /&gt;parent.appendChild(row) ;&lt;br /&gt;XDocument.View.SwitchView("Internal Works");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This does not work but if I replace loop with the following code it works. So my problem then relates to the loop.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;var i = 1;&lt;br /&gt;var test = "my:field" + i;&lt;br /&gt;row.selectSingleNode(test).text = XDocument.DOM.selectSingleNode("//my:fielda1").nodeTypedValue;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Many thanks for continued help, Paul</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/2271.aspx</link><pubDate>Wed, 26 Apr 2006 08:43:40 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2271</guid><dc:creator>Shanthi Reddy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2271.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2271</wfw:commentRss><description>Maybe I am missing something basic, but these are the errors that I see in the code&lt;br /&gt;1. row is an IXMDOMNode not an IXMLDOMNodeList. So row.count would not be correct right? Are you sure that loop is running 61 times? I think you have SelectNodes and do a count on that&lt;br /&gt;2. Also the CloneNode statement needs to go into the loop as well as the append child.</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/2270.aspx</link><pubDate>Tue, 25 Apr 2006 13:23:58 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2270</guid><dc:creator>spudy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2270.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2270</wfw:commentRss><description>Further to my last comment I must add that the original code did not even change the view.&lt;br /&gt;Once I removed the return(i) the view changed but text was not copied to the cloned row.</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/2269.aspx</link><pubDate>Tue, 25 Apr 2006 10:26:54 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2269</guid><dc:creator>spudy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2269.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2269</wfw:commentRss><description>Abhishek, thanks for your response&lt;br /&gt;&lt;br /&gt;This first loop copies each of 61 fields of one row to the cloned node. Only after the copy has run through this first loop 61 times using the row.count it then appends node to parent.&lt;br /&gt;The return statement is a required part of the first loop I thought.  There is then another loop further down, hence two returns.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;while ( i &amp;lt;= fieldnumber )&lt;br /&gt;{&lt;br /&gt;var fieldTitle = "my:field" &amp; i;&lt;br /&gt;var fieldaTitle = "//my:fielda" &amp; i;&lt;br /&gt;row.selectSingleNode(fieldTitle).text = XDocument.DOM.selectSingleNode(fieldaTitle).nodeTypedValue;&lt;br /&gt;i++;&lt;br /&gt;}&lt;br /&gt;return(i);&lt;br /&gt;&lt;/pre&gt;</description></item><item><title>Re: Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/2268.aspx</link><pubDate>Tue, 25 Apr 2006 08:51:16 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2268</guid><dc:creator>Abhishek</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2268.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2268</wfw:commentRss><description>Hi,&lt;br /&gt;&lt;br /&gt;U have given a return(i) statement before appending the cloned node.&lt;br /&gt;Infact u have given this return(i) statement twice.&lt;br /&gt;Remove the return(i) statemtnt that u have placed before appending the cloned node.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// get a reference to the node where the data is to be stored&lt;br /&gt;var row = XDocument.DOM.selectSingleNode("//my:RoomData/my:RoomDetail") ;&lt;br /&gt;// make a copy of the node by cloning it&lt;br /&gt;row = row.cloneNode(true) ;&lt;br /&gt;// set the new values of the rowâ€™s fields. Copying data from my:field1 to myfielda1, my:field2 to my:fielda2 etc.. up to 61 fields&lt;br /&gt;var i = 1;&lt;br /&gt;//count the number of fields in the row&lt;br /&gt;var fieldnumber = row.count;&lt;br /&gt;while ( i &amp;lt;= fieldnumber )&lt;br /&gt;   {&lt;br /&gt;	var fieldTitle = "my:field" &amp; i;&lt;br /&gt;	var fieldaTitle = "//my:fielda" &amp; i;&lt;br /&gt;	row.selectSingleNode(fieldTitle).text = XDocument.DOM.selectSingleNode(fieldaTitle).nodeTypedValue;&lt;br /&gt;    i++;&lt;br /&gt;   }&lt;br /&gt;  &lt;font color="red"&gt; return(i);//This is where the problem lies.Remove this&lt;/font id="red"&gt;&lt;br /&gt;// append the cloned row to the parent node&lt;br /&gt;var parent = XDocument.DOM.selectSingleNode("//my:RoomData") ;&lt;br /&gt;parent.appendChild(row) ;&lt;br /&gt;// Clear the fields from data collection view&lt;br /&gt;var i = 1;&lt;br /&gt;while ( i &amp;lt;= fieldnumber)&lt;br /&gt;   {&lt;br /&gt;	var fieldaTitle = "//my:fielda" &amp; i;&lt;br /&gt;	XDocument.DOM.selectSingleNode(fieldaTitle).text = "";&lt;br /&gt;    i++;&lt;br /&gt;   }&lt;br /&gt;   &lt;font color="blue"&gt;return(i);//I think even this statement should be placed after changing the view.&lt;/font id="blue"&gt;&lt;br /&gt;//now switch from the data collection view &lt;br /&gt;XDocument.View.SwitchView("Internal Works");&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Abhishek</description></item><item><title>Copy data from fields to cloned node</title><link>https://www.infopathdev.com:443/forums/thread/1264.aspx</link><pubDate>Tue, 25 Apr 2006 07:21:11 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:1264</guid><dc:creator>spudy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/1264.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=1264</wfw:commentRss><description>I have a data collection view with dropdowns and text boxes. The save button is supposed to clone a row from a repeating group to store data, then copy the data collection fields into cloned node. This is then appended to parent. &lt;br /&gt;&lt;br /&gt;This works ok:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// get a reference to the node where the data is to be stored&lt;br /&gt;var row = XDocument.DOM.selectSingleNode("//my:RoomData/my:RoomDetail") ;&lt;br /&gt;// make a copy of the node by cloning it&lt;br /&gt;row = row.cloneNode(true) ;&lt;br /&gt;//copy data to cloned node&lt;br /&gt;row.selectSingleNode("my:field1").text = XDocument.DOM.selectSingleNode("//my:field1a").nodeTypedValue;&lt;br /&gt;// append the cloned row to the parent node&lt;br /&gt;var parent = XDocument.DOM.selectSingleNode("//my:RoomData") ;&lt;br /&gt;parent.appendChild(row) ;&lt;br /&gt;// Clear the RoomDetail&lt;br /&gt;XDocument.DOM.selectSingleNode("//my:field1a").text = "";&lt;br /&gt;//change view&lt;br /&gt;XDocument.View.SwitchView("Internal Works");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The problem is that there are 61 fields and obviously I want to avoid repetitive lines of code. So then I tried to perform the copy with looping code. This however does not work but alas an error message is not given. I suspect the problem lies in the count but without error I am lost. Here is the revised code:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// get a reference to the node where the data is to be stored&lt;br /&gt;var row = XDocument.DOM.selectSingleNode("//my:RoomData/my:RoomDetail") ;&lt;br /&gt;// make a copy of the node by cloning it&lt;br /&gt;row = row.cloneNode(true) ;&lt;br /&gt;// set the new values of the rowâ€™s fields. Copying data from my:field1 to myfielda1, my:field2 to my:fielda2 etc.. up to 61 fields&lt;br /&gt;var i = 1;&lt;br /&gt;//count the number of fields in the row&lt;br /&gt;var fieldnumber = row.count;&lt;br /&gt;while ( i &amp;lt;= fieldnumber )&lt;br /&gt;   {&lt;br /&gt;	var fieldTitle = "my:field" &amp; i;&lt;br /&gt;	var fieldaTitle = "//my:fielda" &amp; i;&lt;br /&gt;	row.selectSingleNode(fieldTitle).text = XDocument.DOM.selectSingleNode(fieldaTitle).nodeTypedValue;&lt;br /&gt;    i++;&lt;br /&gt;   }&lt;br /&gt;   return(i);&lt;br /&gt;// append the cloned row to the parent node&lt;br /&gt;var parent = XDocument.DOM.selectSingleNode("//my:RoomData") ;&lt;br /&gt;parent.appendChild(row) ;&lt;br /&gt;// Clear the fields from data collection view&lt;br /&gt;var i = 1;&lt;br /&gt;while ( i &amp;lt;= fieldnumber)&lt;br /&gt;   {&lt;br /&gt;	var fieldaTitle = "//my:fielda" &amp; i;&lt;br /&gt;	XDocument.DOM.selectSingleNode(fieldaTitle).text = "";&lt;br /&gt;    i++;&lt;br /&gt;   }&lt;br /&gt;   return(i);&lt;br /&gt;//now switch from the data collection view &lt;br /&gt;XDocument.View.SwitchView("Internal Works");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Any help would be greatly appreciated.&lt;br /&gt;&lt;br /&gt;Regards&lt;br /&gt;&lt;br /&gt;Spudy</description></item></channel></rss>