The Error object represents a specific error within the Errors collection and is associated to an XML DOM node located in the form s underlying XML. When data validation fails for a particular XML DOM node, an error is created in the Error object and then placed in the Errors collection.
InfoPath supports the following types of validation errors:
Schema_Validation: Data validation failure that occurs as a result of an XML schema constraint
System_Generated: Data validation failure that occurs as a result of constraints defined in the form definition file or the ReportError method
User_Specified: Data validation failure that occurs as a result of custom scripting errors or using the Add method of the Errors collection
The Error object supports the properties and methods shown in Table A.12.
Name | Security Level | Description |
---|---|---|
Node Property | 2 | Is a read-only property that returns a reference to the XML node that is associated with the Error object. |
ShortErrorMessage Property | 2 | Specifies or retrieves the short error message that is returned by the Error object and appears as the tool tip that is viewed by the users when data validation fails. |
Type Property | 2 | Returns the type of the Error object. |
DetailedErrorMessage Property | 2 | Sets or retrieves the detailed error message of the Error object. This is the error message that users can view when data validation fails in their forms. |
ConditionName Property | 2 | Returns the name of the error condition or a null depending on the type of Error object. This property is used for custom errors only and will appear null for all other types. |
ErrorCode Property | 2 | Is a long integer value that sets or retrieves the error codes of the Error object. |
Note | The Type property of the Error object determines the type of data validation that occurred. |
The following example uses the Node property of the Error object to display the XML node of an error:
var objError; objError = XDocument.Errors(0); XDocument.UI.Alert("Name of the Error: " + objError.Node.xml);