This documentation is archived and is not being maintained.

XDocument.OnMergeRequest Event

Office 2007
Occurs when the merge operation is invoked either from the Microsoft Office InfoPath 2007 user interface or from the command line by using the /aggregate option.

Version Information
 Version Added:  InfoPath 2003



expression   An expression that returns a XDocument object.


NameRequired/OptionalData TypeDescription
pEventRequiredMergeEventAn event object that is used during an OnMergeRequest event.

Return Value


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

For InfoPath forms stored in a Windows SharePoint Services 3.0 form library, the OnMergeRequest event also occurs when the MergeDocuments2 method of the OpenXMLDocuments control is executed. For more information on the OpenXMLDocuments control, see the SharePoint Products and Technologies 2003 Software Development Kit, which is available on the Microsoft SharePoint Products and Technologies Web site.

If you create an event handler for the OnMergeRequest event of a form template, you must edit the form definition file (.xsf) to set the useScriptHandler attribute to "yes" before it will run.


In the following example, the OnMergeRequest event handler performs a merge operation, and it sets variables to indicate the status of the merge operation:

var g_fMerging = false;

function XDocument::OnMergeRequest eventObj)
   // Set global property to indicate that forms are being merged.
   if (eventObj.Index == 0)
       g_fMerging = true;

   eventObj.ReturnStatus = true;
   if (eventObj.Index + 1 == eventObj.Count)
      g_fMerging = false;
      XDocument.UI.Alert("Your request to merge " + eventObj.Count +
     " files is now complete.");