I've found code to do the captioned job, but I have some kind of problem.
Here is my code
// Get a copy of the main DOM node.
var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:Table_StaffProfiles").cloneNode(true);
// Clear the main DOM nodes.
XDocument.DOM.selectNodes("/my:myFields/my:Table_StaffProfiles").removeAll();
clone.selectSingleNode("my:EmployeeName_Full").text = "x";
clone.selectSingleNode("my:EmployeeName_SP").text = "";
clone.selectSingleNode("my:EmployeeAddressLine1").text = "";
clone.selectSingleNode("my:EmployeeAddressLine2").text = "";
clone.selectSingleNode("my:EmployeeAddressCity").text = "";
clone.selectSingleNode("my:EmployeeAddressState_Region").text = "";
clone.selectSingleNode("my:EmployeeTitle").text = "";
clone.selectSingleNode("my:EmployeeEmailAddress").text = "";
XDocument.DOM.selectSingleNode("my:myFields").appendChild(clone.cloneNode(true));
// Get the SharePointList DOM
var oSharePointDom = XDocument.GetDOM("Staff Profiles");
// Setup the Namespaces
oSharePointDom.setProperty("SelectionNamespaces", 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');
// Loop through all of the items in the SharePoint List
var nlSharedItems = oSharePointDom.selectNodes("/dfs:myFields/dfs:dataFields/dfs:Staff_Profiles");
while( (nSharedItem = nlSharedItems.nextNode() ) != null )
{
// Create a new row from the sample
var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:Table_StaffProfiles").cloneNode(true);
clone.selectSingleNode("my:EmployeeName_Full").text = nSharedItem.selectSingleNode("EmployeeName_Full").text;
clone.selectSingleNode("my:EmployeeName_SP").text = nSharedItem.selectSingleNode("EmployeeName_SP").text;
clone.selectSingleNode("my:EmployeeAddressLine1").text = nSharedItem.selectSingleNode("EmployeeAddressLine1").text;
clone.selectSingleNode("my:EmployeeAddressLine2").text = nSharedItem.selectSingleNode("EmployeeAddressLine2").text;
clone.selectSingleNode("my:EmployeeAddressCity").text = nSharedItem.selectSingleNode("EmployeeAddressCity").text;
clone.selectSingleNode("my:EmployeeAddressState_Region").text = nSharedItem.selectSingleNode("mployeeAddressState_Region").text;
clone.selectSingleNode("my:EmployeeTitle").text = nSharedItem.selectSingleNode("EmployeeTitle").text;
clone.selectSingleNode("my:EmployeeEmailAddress").text = nSharedItem.selectSingleNode("EmployeeEmailAddress").text;
XDocument.DOM.selectSingleNode("my:myFields").appendChild(clone.cloneNode(true));
}
I get an Error on the Italic Lines. It seems to be nSharedItem.selectSingleNode("EmployeeName_Full").text causing the problem.
The error is
The following error occurred:
Object required
File:script.js
Line:186 is the first italic line. If I replace the nSharedItem.selectSingleNode("EmployeeName_Full").text with plain text, I get no problem, and it iterates through the whole data set.
What am I doing wrong?
Mo