XDocument.OnSubmitRequest Event

InfoPath Developer Reference

Occurs when the submit operation is invoked either from the Microsoft Office InfoPath 2007 user interface or by using the Submit method of the XDocument object in the InfoPath object model.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.OnSubmitRequest(pEvent)

expression   An expression that returns a XDocument object.

Parameters

Name Required/Optional Data Type Description
pEvent Required DocReturnEvent An event object that is used during a Microsoft Office InfoPath 2007 load or submission event.

Return Value
nothing

Remarks

This event handler allows users to cancel an operation.

If the ReturnStatus property of the DocReturnEvent object is set to False, InfoPath cancels the submit operation. If an error occurs in the scripting code for the OnSubmitRequest event handler, InfoPath ignores it and relies on the ReturnStatus property of the DocReturnEvent object. If the ReturnStatus property is not explicitly set, the default value of False is used.

Example

In the following example, the OnSubmitRequest event handler is used to create an XMLHTTP object for transporting the form's underlying XML document:

JScript
  function XDocument::OnSubmitRequest eventObj)
{
   // Create an XMLHTTP object for document transport.
   try
   {
      var objXmlHttp = new ActiveXObject("MSXML2.XMLHTTP.5.0");
   }
   catch(ex)
   {
      XDocument.UI.Alert("Could not create MSXML2.XMLHTTP 
         object.\r\n" + ex.number + " - " + ex.description);
  // Return is equivalent to setting eventObj.ReturnStatus = false, 
  // because no change was made to this value.
  return;	

}

// Post the XML document to strUrl. objXmlHttp.open("POST", strUrl, false); try { objXmlHttp.send(XDocument.DOM.xml); } catch(ex) { XDocument.UI.Alert("Could not post (ASP) document to " + strUrl + "\r\n" + ex.number + " - " + ex.description);

  // Return is equivalent to setting eventObj.ReturnStatus = false.
  return;

} // If here, the submit operation is has been successful. eventObj.ReturnStatus = true; }

See Also