Infopath 2007 Set xsi:nil on FormServices

In InfoPath 2007 the fields wich type is one of the following:

  • Whole Number (integer)
  • Decimal (double)
  • Date (date)
  • Time (time)
  • Date and Time (dateTime)

If you try to set that field value programaticaly without clearing the xsi:nil attribute you will get an “Schema validation found non-data type errors.”

For more information: http://blogs.msdn.com/infopath/archive/2006/11/28/the-xsi-nil-attribute.aspx

But if you want to later clear that field value you will need to set the xsi:nil attribute back to true.

If you try to create the attribute using the CreateAttribute, it works on the full client but it wont work on the Sharepoint Forms Server.

The only way that I found to make this work in a “clean” way was like this:

XPathNavigator nodeToClear = xDoc.SelectSingleNode(“xpathtonode”, this.NamespaceManager);

nodeToClear.ReplaceSelf(string.Format("<{0} xsi:nil=’true’/>", nodeToClear.Name));

Hope it helps…

Advertisements

One thought on “Infopath 2007 Set xsi:nil on FormServices

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s