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