OnSubmitRequest Event

Microsoft Office InfoPath

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

Function XDocument::OnSubmitRequest(ByRef pEvent As DocReturnEvent)

pEvent Required DocReturnEvent. A reference to the DocReturnEvent object.

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:

function XDocument::OnSubmitRequest(eventObj)
{
   // Create an XMLHTTP object for document transport.
   try
   {
      var objXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
   }
   catch(ex)
   {
      XDocument.UI.Alert("Could not create MSXML2.XMLHTTP 
         object.\r\n" + ex.number + " - " + ex.description);

      // Return with 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 with eventObj.ReturnStatus == false.
      return;
   }
   // If here, the submit operation is has been successful.
   eventObj.ReturnStatus = true;	
}