[b]Infopath XML insertBefore method[/b] - InfoPath Dev
in

InfoPath Dev

[b]Infopath XML insertBefore method[/b]

Last post 02-28-2006 01:26 PM by Agni Jonnalagadda. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-28-2006 10:24 AM

    [b]Infopath XML insertBefore method[/b]

    I hope this is the right place to ask this question. I have an Infopath form that has the following structure:

    my:Fields
    my:Customer
    my:WorkOrder (repeating)
    my:otherfields

    When I use the insertBefore method to insert another my:WorkOrder node, it does not insert it, it replaces the existing my:WorkOrder node. I have used the same code in two other forms with similar structures,and it works fine.

    Here's the code:

    function AppendOrInsertNewNode(Parent, StrNode, NodeToAppend)
    {
    /** Set all Nodes count to zero so we can get an accurate count of each.**/
    var LastChildNodeWithCorrectTag = 0;


    //Go through all Child Nodes that we want OF WorkOrder and get a count of each.
    for(var i = 0; i<Parent.childNodes.length;i++)
    {
    if(Parent.childNodes(i).tagName == StrNode)
    {
    LastChildNodeWithCorrectTag = i;
    }
    }
    try
    {
    Parent.insertBefore(NodeToAppend, Parent.childNodes(LastChildNodeWithCorrectTag).nextSibling);
    }
    catch(er)
    {
    XDocument.UI.Alert("Can't insert before: " + er.message)
    }

    }

    The Parent is sent as the my:Customer node, the nodeToAppend is a clone of the my:WorkOrder node with the text of each child node changed.

    Any help would be appreciated?

    Patti
  • 02-28-2006 01:26 PM In reply to

    Re: [b]Infopath XML insertBefore method[/b]

    Hi,
    I think there might be a mistake where you have actually cloned the node, you might be assigning the cloned node instead of cloned node to "NodeToAppend" variable. Just look at the code that you have written to clone the node.
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.