There were following fields for each question:
Question Text
CheckBox as answer
Textbox (If required)
Now after populating them we need to save all the answers into form. But here we are not sure how many questions will be there as they are auto populated from SharePoint List so we cannot save each answer into seperate field into form, and I used delimited text for this pupose.
vb.Net Code:
Code to popluate the questions at runtime:
[ Edit flag is used to control the repeater section insert, remove functions as these sections get populated at runtime so user will not have option to inset or remove any section. For this purpose I had to create a flag for a rule which will disable these functions when my flag is false ]
Dim editFlag As IXMLDOMNode = thisXDocument.DOM.selectSingleNode("/my:TMS/my:GeneralChecklistGroup/my:EditFlag")
editFlag.text = "1"
Dim xDocumentQA As IXMLDOMDocument2 = DirectCast(thisXDocument.GetDOM("Check List Questions"), IXMLDOMDocument2)
xDocumentQA.setProperty("SelectionNamespaces", "xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution""")
Dim nodeRoot As IXMLDOMNode = xDocumentQA.selectSingleNode("dfs:myFields")
If nodeRoot.childNodes(0).childNodes(0).attributes(1).text = "1" Then
myQAGroup.childNodes(1).childNodes(1).text = " " + nodeRoot.childNodes(0).childNodes(0).attributes(0).text 'Text;
Else
myQAGroup.childNodes(1).childNodes(1).text = nodeRoot.childNodes(0).childNodes(0).attributes(0).text 'Text;
End If
myQAGroup.childNodes(1).childNodes(5).text = nodeRoot.childNodes(0).childNodes(0).attributes(2).text 'TextBoxRequired
myQAGroup.childNodes[1].childNodes[11].text = nodeRoot.childNodes[0].childNodes[0].attributes[4].text 'ID
Dim intCtr As Integer = nodeRoot.childNodes(0).childNodes.length - 1
For i As Integer = 0 To nodeRoot.childNodes(0).childNodes.length - 2
Dim myQAInsertSection As IXMLDOMNode = thisXDocument.DOM.selectSingleNode("/my:TMS/my:GeneralChecklistGroup/my:Questions/my:QuestionsSection")
thisXDocument.View.SelectNodes(myQAInsertSection, Type.Missing, Type.Missing)
thisXDocument.View.ExecuteAction("xCollection::insert", "QuestionsSection_140")
If nodeRoot.childNodes(0).childNodes(intCtr).attributes(1).text = "1" Then 'IsOption
myQAGroup.childNodes(3).childNodes(1).text = " " + nodeRoot.childNodes(0).childNodes(intCtr).attributes(0).text 'Text
Else
myQAGroup.childNodes(3).childNodes(1).text = nodeRoot.childNodes(0).childNodes(intCtr).attributes(0).text 'Text
End If
myQAGroup.childNodes(3).childNodes(5).text = nodeRoot.childNodes(0).childNodes(intCtr).attributes(2).text 'TextBoxRequired