I am trying to copy a sharepoint list data into Main data source... Here is the script I have - the problem is it is not going inside the While loop for the insertion process.. Any help is appreciated
function CTRL79_5::OnClick(eventObj)
{
XDocument.UI.Alert("Begin Code");
var extlist =XDocument.GetDOM("PhaseMetrics").selectNodes("/Phase_Metrics");
XDocument.UI.Alert("After the first list");
// If nothing was found, then return; there will be no items to insert. if(extlist == null)
{
XDocument.UI.Alert("Nothing was returned");
return;
}
XDocument.UI.Alert("Before the Insertion point");
// Get the Metrics insertion point.var metricList = XDocument.DOM.selectSingleNode("/my:myFields/my:Financial/my:Fin_Phase_Metrics");
XDocument.UI.Alert("After the Insertion point");
// Add the rows to the main DOM.var metric;
XDocument.UI.Alert("Before the Loop");
while(metric = extlist.nextNode())
{
try
{
// Get this Phase Metrics values from the secondary DOM.
XDocument.UI.Alert("Inside the loop");
var bcws = metric.selectSingleNode("@BCWS").text;
var bcwp = metric.selectSingleNode("@BCWP").text;var acwp = metric.selectSingleNode("@ACWP").text;
var name = metric.selectSingleNode("@Name").text;var start = metric.selectSingleNode("@Start").text;var finish = metric.selectSingleNode("@Finish").text;
// Build a string representing a main DOM nodeset using the values from the secondary DOM.var metricXml = "<my:Fin_Phase_Metrics xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-06-03T00:09:57'>"
+ "<my:Fin_Phase_BCWS>" + bcws + "</my:Fin_Phase_BCWS>"
+ "<my:Fin_Phase_BCWP>" + bcwp + "</my:Fin_Phase_BCWP>"
+ "<my:Fin_Phase_ACWP>" + acwp + "</my:Fin_Phase_ACWP>"
+ "<my:Fin_Phase_Name>" + name + "</my:Fin_Phase_Name>"
+ "<my:Fin_Phase_Start>" + start + "</my:Fin_Phase_Start>"
+ "<my:Fin_Phase_Finish>" + finish + "</my:Fin_Phase_Finish>";
XDocument.UI.Alert("After the XML Line");
metricXml += "</my:Fin_Phase_Metrics>";
// Load string into a temporary XML DOM.var domNewRow = XDocument.CreateDOM();
domNewRow.validateOnParse =
false;domNewRow.async = false;
domNewRow.loadXML(metricXml);
domNewRow.setProperty("SelectionNamespaces", 'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-06-03T00:09:57"');
// Insert into the main DOM.
metricList.appendChild(domNewRow.selectSingleNode("my:Fin_Phase_Metrics"));
}
catch(ex)
{
XDocument.UI.Alert("Could not insert Phase Metric row.\n\nError message:\n" + ex.Message);
}
}
XDocument.UI.Alert("After the loop");
}
Based on the displays, I am going till the While loop and not inside it...