_XDocumentEventSink2_Event.OnMergeRequest Event

Definition

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

public:
 event Microsoft::Office::Interop::InfoPath::SemiTrust::_XDocumentEventSink2_OnMergeRequestEventHandler ^ OnMergeRequest;
event Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnMergeRequestEventHandler OnMergeRequest;
member this.OnMergeRequest : Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnMergeRequestEventHandler 
Event OnMergeRequest As _XDocumentEventSink2_OnMergeRequestEventHandler 

Event Type

Examples

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

private bool _merging = false;

[InfoPathEventHandler(EventType=InfoPathEventType.<span class="label">OnMergeRequest</span>)]
public void OnMergeRequest(MergeEvent e)
{ 
 // Set global property to indicate that forms are being merged.
 if (e.Index == 0)
 {
  _merging = true;
 }

 thisXDocument.ImportDOM(e.DOM);
 e.ReturnStatus = true;

 if ((e.Index + 1) == e.Count)
 {
  _merging = false;
  thisXDocument.UI.Alert("Your request to merge " + e.Count + " files is now complete.");
 }
}

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

private bool _merging = false;

[InfoPathEventHandler(EventType=InfoPathEventType.<span class="label">OnMergeRequest</span>)]
public void OnMergeRequest(MergeEvent e)
{ 
 // Set global property to indicate that forms are being merged.
 if (e.Index == 0)
 {
  _merging = true;
 }

 thisXDocument.ImportDOM(e.DOM);
 e.ReturnStatus = true;

 if ((e.Index + 1) == e.Count)
 {
  _merging = false;
  thisXDocument.UI.Alert("Your request to merge " + e.Count + " files is now complete.");
 }
}

Remarks

If the ReturnStatus property of the MergeEventObject object is set to false, InfoPath cancels the merge operation. If an error occurs in the code for the OnMergeRequest event, InfoPath ignores the error and relies on the ReturnStatus property 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 Microsoft SharePoint Products and Technologies 2003 Software Development Kit

Note: There is no user interface (UI) in the InfoPath form design window for creating this event handler. To add this event handler to the project, include the InfoPathEventHandler attribute as it appears in the example.

Applies to