XDocument.OnSaveRequest Event

InfoPath Developer Reference

Occurs when the save operation is invoked from the Microsoft Office InfoPath 2007 user interface or by using the Save or SaveAs method of the XDocument object in the InfoPath object model.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.OnSaveRequest(pEvent)

expression   An expression that returns a XDocument object.

Parameters

Name Required/Optional Data Type Description
pEvent Required SaveEvent An event object that is used during an OnSaveRequest event.

Return Value
nothing

Remarks

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

The ReturnStatus property works in conjunction with the IsCancelled property when the InfoPath form is closing. If the document has changes that have not been saved and the user cancels the save operation, the IsCancelled property can be set to True to allow InfoPath to close.

Example

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

JScript
  function XDocument::OnSaveRequest eventObj)
{
	// Write the code to be run before saving here.
XDocument.UI.Alert("Begin saving form.");

eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.

XDocument.UI.Alert("Form saved.");

eventObj.ReturnStatus = true;

}

See Also