Clearing Date Fields in Managed Codes

B

BethA

I would like to clear some date fields as part of some managed code behind a
button on my form. I can do it through rules, but I can't figure out how to
make it work in code. Help would be appreciated!

Thanks,
Beth A.
 
S

S.Y.M. Wong-A-Ton

Clear the contents of the date field and then add an xsi:nil attribute to the
node.

In C# code for InfoPath 2003:

thisXDocument.DOM.selectSingleNode("//my:dateField").text = "";
IXMLDOMNode attr = thisXDocument.DOM.createNode(DOMNodeType.NODE_ATTRIBUTE,
"nil", "http://www.w3.org/2001/XMLSchema-instance");
attr.text = "true"
thisXDocument.DOM.selectSingleNode("//my:dateField").attributes.setNamedItem(attr);
 
Top