This documentation is archived and is not being maintained.

Error Object

Office 2007
Represents an error in a Microsoft Office InfoPath 2007 form.

Version Information
 Version Added:  InfoPath 2003

Remarks

Each Error object in InfoPath is each associated with an XML Document Object Model (DOM) node from a form's underlying XML document. When data validation fails for a particular XML DOM node, InfoPath creates an Error object and places it in the Errors collection.

That are three types of data validation errors that can occur in an InfoPath form:

  • SCHEMA_VALIDATION  Data validation failed as a result of an XML Schema–defined constraint.
  • SYSTEM_GENERATED  Data validation failed as a result of constraints defined in the form definition (.xsf) file or as a result of scripting code calling the ReportError method of the DataDOMEvent object.
  • USER_SPECIFIED  Data validation failed as a result of a custom scripting error using the Add method of the Errors collection.
Bb229854.vs_note(en-us,office.12).gif  Note
The Type property of the Error object can be used to determine the type of data validation error that has occurred.

The Error object provides a number of properties that can be used to programmatically interact with an InfoPath data validation error. The Error object is accessed through the Errors property of the XDocument object, which returns a reference to the Errors collection.

For more information about using the Error object, see Handling errors.

Example

In the following example, the Item property of the Errors collection is used to set a reference to an Error object; then the ShortErrorMessage property of the Error object is is used to display the error message in a message box:

JScript
var objError;

objError = XDocument.Errors(0);
XDocument.UI.Alert("Error message: " + objError.ShortErrorMessage);



Show: