Export (0) Print
Expand All

XDocument.OnSaveRequest Event

Office 2007
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



expression   An expression that returns a XDocument object.


NameRequired/OptionalData TypeDescription
pEventRequiredSaveEventAn event object that is used during an OnSaveRequest event.

Return Value


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.


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

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;

Community Additions

© 2014 Microsoft