Hello,
I'm trying to write a javascript for the on_load event of my infopath form.
The main body of my form is contained within a repeating section. Every time the user opens the infopath form I want the top node in the repeating section to be cloned and placed at the top as a kind of version control mechanism.
I have tried the following code:
function XDocument::OnLoad(eventObj)
{
var parent = XDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:versions");
var newChild = parent.selectSingleNode("my:version[1]").cloneNode(true);
parent.insertBefore(newChild,parent.selectSingleNode("my:version[1]"));
}
The error that I am getting is that the new my:version child element is "unexpected according to content model of parent element"
This makes no sense to me because the my:version element definately belongs to the my:versions parent element in the xml data structure that is produced by the infopath form.
I'm pretty new to both infopath and xml scripting so any help you can offer me would be extremely helpful
Many Thanks