<?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: Identify last node of repeating group</title><link>https://www.infopathdev.com:443/forums/thread/2165.aspx</link><pubDate>Tue, 11 Apr 2006 11:59:27 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:2165</guid><dc:creator>spudy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/2165.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=2165</wfw:commentRss><description>Ok, so this is a bit embarassing now. I have realised that the while statement is exiting before the last node is reached. Not really an infopath issue.</description></item><item><title>Identify last node of repeating group</title><link>https://www.infopathdev.com:443/forums/thread/1242.aspx</link><pubDate>Tue, 11 Apr 2006 11:29:55 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:1242</guid><dc:creator>spudy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/1242.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=1242</wfw:commentRss><description>&lt;br /&gt;&lt;br /&gt;I have a filtered list of items. The first row in the list has an itemNumber field with a value of 0 as applied on the template.xml. &lt;br /&gt;&lt;br /&gt;I have a button to add a new item. When pressed the view is changed to an input form. On the input form I have a field newitemNumber.&lt;br /&gt;&lt;br /&gt;I wish to take the value of the last itemNumber from the list, increment by 1 and apply this to the field newitemNumber. This will then provide a unique identifier for when the save button creates a new item and adds to the list.&lt;br /&gt;&lt;br /&gt;My code follows, guess what...it doesn't work. The list is empty, new item button is actioned and the input form has unique value of 1, which is to be expected. When the button is actioned another time, the value stays at 1 instead of incrementing by 1.&lt;br /&gt;&lt;br /&gt;I feel sure using the LastNode property would be a better approach but I haven't got that far yet. any help would be appreciated.&lt;br /&gt;&lt;br /&gt;var itemList = XDocument.DOM.selectNodes( "/my:Fields/my:RoomData/my:RoomDetail" );&lt;br /&gt;var iNumber = 0;&lt;br /&gt;while( row = itemList.nextNode() )&lt;br /&gt;{&lt;br /&gt;	var getUniqueID = getNodeTypedValue(row.selectSingleNode( "my:itemNumber" ));&lt;br /&gt;	iNumber += getUniqueID&lt;br /&gt;}&lt;br /&gt;var UniqueID = iNumber + 1;&lt;br /&gt;XDocument.View.SwitchView("Input Form");&lt;br /&gt;XDocument.DOM.selectSingleNode("//my:newItemNumber").text = UniqueID;&lt;br /&gt;&lt;br /&gt;Regards Spudy</description></item></channel></rss>