OnMergeRequest Event

Microsoft Office InfoPath

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

Function XDocument::OnMergeRequest(ByRef pEvent As MergeEvent)

pEvent    Required MergeEvent. A reference to the MergeEvent object.

Remarks

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 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.

Note  This object model member is not supported when the Disable Service Pack features option on the Advanced tab of the Options dialog box in InfoPath is selected or when Microsoft Office 2003 Service Pack 1 or later is not installed. Any form that implements this object model member in its code will generate an error message if it is opened in InfoPath when service pack features are disabled or unavailable.

Example

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;

   XDocument.ImportDOM(eventObj.DOM);
   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.");
   }
}