DataDOMEvent.ReportError Method

InfoPath Developer Reference

Creates an Error object and adds it to the Errors collection.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.ReportError(varNode, bstrShortErrorMessage, fSiteIndependent, bstrDetailedErrorMessage, lErrorCode, bstrType)

expression   An expression that returns a DataDOMEvent object.

Parameters

Name Required/Optional Data Type Description
varNode Required Variant The XML Document Object Model (DOM) node that the error is associated with.
bstrShortErrorMessage Required String The text to be used for the short error message.
fSiteIndependent Required Boolean Sets the condition for automatic deletion of the Error object. If True, the Error object will be deleted on change for any nodes that matched the XPath expression corresponding to the Error object. If False, the Error object will be deleted when the node returned by the Site property of a given event object has been changed.
bstrDetailedErrorMessage Optional String The text to be used for the detailed error message.
lErrorCode Optional Long The number to be used as the error code.
bstrType Optional String Default value is "modeless". Determines whether the change in value will be automatically rejected or whether the user will be prompted to accept or reject the change. The other value is "modal".

Return Value
Error

Remarks

When the ReportError method of the DataDOMEvent object is called, Microsoft Office InfoPath 2007 creates an Error object and adds it to the Errors collection. Errors are removed from the collection when the validation constraint is no longer invalid, or when they are explicitly removed using the Delete or DeleteAll methods of the Errors collection.

Bb229811.vs_note(en-us,office.12).gif  Note
The Delete method will only delete errors that were created using the Add method of the Errors collection. It cannot be used to delete errors that occur because of schema or data validation constraints, or errors that were created using the ReportError method of the DataDOMEvent object.

Errors can also be created using the Add method of the Errors collection.

Bb229811.vs_note(en-us,office.12).gif  Note
Site-independent errors should be used when you want the errors to apply to all XML DOM nodes of the same type. If you want the error to apply to a specific XML DOM node, use site-dependent errors.

Security Level 2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Example

In the following example, the ReportError method of the DataDOMEvent object is used to create a custom error and add it to the errors collection:

JScript
  function msoxd__total::OnValidate(eventObj)
{
   if (parseInt(eventObj.Site.nodeTypedValue, 10) > 75)
      eventObj.ReportError eventObj.Site, "The total is too high.  " +
         "The total number of blocks cannot be greater than 75.", false);

if (parseInt(eventObj.Site.nodeTypedValue, 10) < 0) eventObj.ReportError eventObj.Site, "The total is too low. " + The total number of blocks cannot be less than 0.", false); }

See Also