Validation script for checkbox

S

sripri96

Hi:

I have a repeating table that has several columns and one of them is a
checkbox. I want to perform the following task: Once the checkbox is
"checked", it should copy the entire row and paste it in another table. Can
this be done? I am new to InfoPath, so any tip on this would be great!!

Thanks,
sripri96
 
F

Franck Dauché

Hi,

You need to catch the OnAfterChange event. If you have 3 fields in group2,
and that your checkbox is linked to field1:

[InfoPathEventHandler(MatchPath="/my:myFields/my:group1/my:group2/my:field1", EventType=InfoPathEventType.OnAfterChange)]
public void field1_OnAfterChange(DataDOMEvent e)
{
if (e.IsUndoRedo) {return;}
test(e);
}
private void test(DataDOMEvent e)
{
IXMLDOMNode oNode = e.Site.selectSingleNode("..");
IXMLDOMNode oField2 = oNode.selectSingleNode("my:field2");
IXMLDOMNode oField3 = oNode.selectSingleNode("my:field3");
//you can assign oField2.text and oField3.text to other nodes or use
appendChild (see below) in another repeating section....
}

To appendChild use something like:
IXMLDOMDocument2 templateDom = (IXMLDOMDocument2)thisXDocument.CreateDOM();
templateDom.validateOnParse = false;
templateDom.load("template.xml");
templateDom.setProperty("SelectionNamespaces",
"xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-10T17-59-19'");
IXMLDOMNode oTemplateGrp =
templateDom.selectSingleNode("/my:myFields/my:group1/my:group2");
IXMLDOMNode oTemplateNode = oTemplateGrp.cloneNode(true);
IXMLDOMNode oGroup1 =
thisXDocument.DOM.selectSingleNode("/my:myFields/my:group1");
oGroup1.appendChild(oTemplateNode);

Hope that it helps.

Regards,

Franck Dauché
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top