01 febrero 2009

Infopath and Forms Server: Schema validation found non-datatype errors

While developing a browser enabled Infopath 2007 Form with code I got this
error: " Schema validation found non-datatype errors".

The error was thrown when I tried to set a field of the form to a blank
value (String.Empty).

XPathNavigator nav =
this.MainDataSource.CreateNavigator().SelectSingleNode("/my:" +
DATASOURCE_ROOT + "/my:" + field, NamespaceManager);


After many times of trial and error I found that the problem was actually to
set a value to a field that had not had yet a value, so just making this
check was enough:

if (nav.Value != value)

I.e. if the value is still empty and I want to set String.Empty it actually
does nothing.

No hay comentarios: