Populate repeating table from another view - InfoPath Dev
in

InfoPath Dev

Populate repeating table from another view

Last post 03-14-2006 04:39 AM by Abhishek. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-13-2006 08:18 AM

    Populate repeating table from another view

    Sorry - I posted this last week with a misleading title (Populate repeating table from another FORM).

    I have a repating table, say Orders. I want users to add orders by clicking an "Add Order" button. This will open a new view for filling an order, which could be quite detailed. Upon hitting the OK button on this Order view it should be closed and the data should be added as another row in the repating table on the main view.

    I bound both the repeating table and the control on the Orders form to the same (repeating) schema element. However the default behavior seems to be that a new entry made in the Order form replaces the previous one, i.e. when I close it I still have only one row in the repeating table, with the new order data, instead of having a new row appended.

    How can I do this? Do I need code?

    -- Shaul
  • 03-14-2006 04:39 AM In reply to

    Re: Populate repeating table from another view

    Hi Shaul,
    I have exactly the same situation as u described above.And I used code to implement this.

    And most importantly,dont bind the controls in the Order view to the repeating table.Keep separate fields to accept Order details in the Order view.
    Assume that my datasource has the following structure
    Rootnode
    Group
    Repeating Group

    Steps involved
    1)On clicking the "Add Order" button,switch views to the Order view.(Use rules)
    2)Keep separate fields in the Order view.
    3)For the OK button's OnClick event,Add code to add a row to the Orders repeating table with the new details from the Orders view.
    Code sample is

    IXMLDOMDocument2 templateDom = (IXMLDOMDocument2)thisXDocument.CreateDOM();
    templateDom.validateOnParse = false;
    templateDom.load("template.xml");
    templateDom.setProperty("SelectionNamespaces", "xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-11-02T09:58:08'");
    IXMLDOMNode oTemplateGrp = templateDom.selectSingleNode("/rootnode/group/repeating group");
    //Make a copy of ur Repeating Group row.
    IXMLDOMNode oTemplateNode = oTemplateGrp.cloneNode(true);

    //Transfer the value from the field in Orders view to the field in ur Cloned node.
    oTemplateNode.selectSingleNode("fieldname in the repeating group").text=thisXDocument.DOM.selectSingleNode("XPath of the field in your Order view").nodeTypedValue.ToString();
    IXMLDOMNode oGroup1 = thisXDocument.DOM.selectSingleNode("/root node/group");
    //Finally append the cloned row to the end of the repeating group
    oGroup1.appendChild(oTemplateNode);

    4)Now switch the view back to the original view from the Orders view using ..
    thisXDocument.View.SwitchView("view name");


    Regards,
    Abhishek
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.