Hi,
I am new to InfoPath coding and currently use JScript and Microsoft Script Editor environment to create some simple scripts for software test tracking.
To date I have picked up quite a few hints on this forum that has helped me immensely. One of the problems I am facing currently is being able to update the value of a node in an infoPath Schema by using JScript Code.
I am using InfoPath forms to create Test Scripts and track their execution & results. Each script has a number of test steps and as the testers execute the scritps they record Pass/Fail against each step and then record a defect id against the specific row. At the end when the tester clicks the submit button, I have the form save a copy to a Test Execution library and publish some of the form values in the list - such as Test Script name, date executed, tester, final outcome, All Defect IDs.
It is with publishing all Defect IDs that I am facing a problem. The Form XML Structure is something like this.
<Test Case Name>
<Test Header Information>
[Series of nodes to capture execution date, tester, final result, All Defects, etc]
<Test Script Steps> 1..* rows depending on the number of steps
<StepNum> [Auto number]
<Condition and Action> [Rich Text Field]
<Expected Result> [Rich Text Field]
<Result> [Combo - Pass / Fail]
<Defect ID> [Text string]
The code below is executed when I click on a button to "Get all defects". This is done before sumbitting the result.
This script works fine until it has to update the value of the All Defects node with the concatenated values of the available defect ids in each failed step.
I do not know which XML method to use to update the value of the AllDefectIDs node.
quote:
//This function concatenates all Defect IDs in the form
function btnGetDefectIDs::OnClick(eventObj)
{
// Write your code here
var numRows, currRow ; // integer
var objRepeatingTable ; // XML of document
var nodeAllDefects ; // For AllDefects
var nodeTestExecutionSummary ; // For TestExecutionSummary
var currDefectID, allDefectIDs ; // strings for defect ids
// initialise values
allDefectIDs = "";
objRepeatingTable = XDocument.DOM.selectNodes( "/my:TestCaseDocument/my:TestCaseSteps/my:TestCaseTable");
numRows = objRepeatingTable["length"];
// Iterate through rows and get Defect IDs
for (currRow = 1; currRow <= numRows; currRow++)
{
currDefectID = (XDocument.DOM.selectSingleNode("//my:TestCaseTable["+ currRow +"]/my:DefectID").text)
if (currDefectID != "")
{
if (allDefectIDs == "")
allDefectIDs = currDefectID ; // for first defect only
else
allDefectIDs = allDefectIDs + "," + currDefectID ; // for all other defects
}
}
//Debug - Display all defects
XDocument.UI.Alert("Value of Defects = " + allDefectIDs);
//Set Value of AllDefects Node
nodeAllDefects = XDocument.DOM.selectSingleNode("/my:TestCaseDocument/my:TestExecutionSummary/my:AllDefects");
nodeAllDefects.setAttributeNode(allDefectIDs); // <-- Unable to set value of Node here
XDocument.UI.Alert("AllDefects value has been set!");
} // end of btnGetDefectIDs
Any advise will be greatly appreciated.
Thanks
Nara