Identify last node of repeating group - InfoPath Dev
in

InfoPath Dev

Identify last node of repeating group

Last post 04-11-2006 04:59 AM by spudy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-11-2006 04:29 AM

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Identify last node of repeating group



    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.

    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.

    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.

    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.

    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.

    var itemList = XDocument.DOM.selectNodes( "/my:Fields/my:RoomData/my:RoomDetail" );
    var iNumber = 0;
    while( row = itemList.nextNode() )
    {
    var getUniqueID = getNodeTypedValue(row.selectSingleNode( "my:itemNumber" ));
    iNumber += getUniqueID
    }
    var UniqueID = iNumber + 1;
    XDocument.View.SwitchView("Input Form");
    XDocument.DOM.selectSingleNode("//my:newItemNumber").text = UniqueID;

    Regards Spudy
  • 04-11-2006 04:59 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Identify last node of repeating group

    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.
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.