MergeCustomers

 

MergeCustomers

Initial Build 2013.01
xWeb Web Method
Response Type XML Results

The MergeCustomers web method merges one or more duplicate customers with a "surviving" customer who will absorb the data of the duplicate customers. If the merge is successful, then the duplicates are deleted or hidden. This web method runs the same logic as the Combine/Merge feature in iWeb. See that page for more context on this operation and for a visual look at how the user inferface appears to staff users.

The cst_key_keep parameter in the request is the Customer Key of the "surviving" customer that you want to keep; typically this is the customer who has more history and data.

The second parameter is an array of one or more MergeCustomer elements, each of which represents a duplicate customer that should be merged with the "survivor" customer specified by the cst_key_keep parameter. In most cases, you will pass only one MergeCustomer but you could pass more than one if a customer has two or more duplicate customers.

The MergeCustomer element also contains an AfterMergeAction property which may be either Hide or Delete. Hide will Hide / Disable the duplicate customer. Delete will physically delete it from the database. The duplicate customer will be hidden or deleted only if the merge was successful. See Hide/Disable for more on this distinction.

The MergeCustomer element also contains a Modules array in which you can specify which of 36+ specific netFORUM Modules (such as Address, Phone, Email, Fundraising, etc.) you want to merge. You may pass specific modules or pass null or omit the element to signify that you want to merge data from all the modules. If you do specify one or more modules, be aware that if you also specify the Delete option for the AfterMergeAction, if there is any data from modules that you excluded, then the Delete may fail because of foreign key constraints in the database.

The response of the method provides a status of the merge as well as error messages, if any.

The Combine/Merge operation is an intensive process that runs 100+ SQL update commands to transfer any data from the duplicate customer to the “survivor” customer, and therefore it can take several seconds to complete.

In order to run this method, the xWeb User must have XWeb User Object Security configured for the Customer table and the Delete operation.

Parameters

The request contains the following parameters:

Name Type Occurs Description
cst_key_keep guid 1..1 The Customer Key of the Customer to keep.
customersToMerge Array of MergeCustomer objects 1..0(R) The customer(s) you want to merge.

 

MergeCustomer

Name Type Occurs Description
cst_key guid 1..1 Customer Key of the duplicate customer.
AfterMergeAction AfterMergeAction 1..1 Hide or Delete
Modules Array of Strings 1..0 An array of strings, each array element named Module. If you just want to merge all modules, then don't pass this element at all or pass it with no Module elements. The list of available modules is available in GetMergeCustomerModules.

 

AfterMergeAction

A string enumeration that can be either of:

  • Hide
  • Delete

After a successful merge, the duplicate customer can be either Hide/Disabled or deleted from the database, depending on the option chosen.

Response

The response is a MergeCustomersResults.

The MergeCustomersResults echoes back the cst_key_keep value and a message that may contain an error message from the Hide/Disable operation.

The return also will contain one MergeCustomerResult element for each MergeCustomer you passed in the request. The MergeCustomerResult echoes back the cst_key and AfterDeleteAction, as well as a Status that can be any of Merged, UnProcessed or Error.

MergeCustomersResults

Name Type Occurs Description
cst_key_keep guid 1..1 Echoes back Customer Key to Keep in the request.
CustomerResults Array of MergeCustomerResult 0..1 One MergeCustomerResult for each customer that was provided as a MergeCustomer in the request.
ErrorMessage string 0..1 Error Message, if any.

 

MergeCustomerResult

This element contains the results of the merge of a specific customer. For each MergeCustomer passed in the request, there will be a corresponding MergeCustomerResult in the response.

Name Type Occurs Description
cst_key guid 1..1 Echoes back the cst_key passed in the request.
AfterMergeAction AfterMergeAction 1..1 Echoes back the AfterMergeAction in the request.
Status MergeResult 1..1 The Status
ModuleResults Array Of ModuleResult 0..1 An array of ModuleResult elements, one for each module.

 

ModuleResult

Each Module that was attempted to merge will be represented by a ModuleResult.

Name Type Occurs Description
Module string 0..1 The name of the Module.
ErrorMessage string 0..1 An error message if the module could not merge successfully.
Status MergeResult 1..1 The status/result code for the merger of the module.

 

MergeResult

The results or status of the merge, which can be any of these three enumerations.

A MergeResult is returned for both the MergeCustomerResult and the ModuleResult. For the former, the MergeResult indicates the status of the merge of the customer. For the latter, the MergeResult indicates the status of the merge of just that one module for that one customer.

  • Merged: Success. When set at the MergeCustomerResult level, this means the customer was merged successfully. When set at the ModuleResult level, this means the module was merged successfully for that MergeCustomer.
  • Error: An error occurred during the Merge
  • UnProcessed: If an earlier customer failed to merge, then the operation will stop processing and this status will be returned. You may choose to try to merge the customer (or module) again separately.

Note that if you try to merge two duplicate customers with one customer, it's possible that the first customer can merge successfully but the second customer fails.

Sample Requests

Request to Merge All Modules

Omit the Modules element in the MergeCustomer, or pass an empty value in it, to merge all modules:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<AuthorizationToken>
<Token>**************</Token>
</AuthorizationToken>
</soapenv:Header>
<soapenv:Body>
<MergeCustomers>
<cst_key_keep>cec29726-4a26-4c07-9162-048020e42241</cst_key_keep>
<customersToMerge>
<MergeCustomer>
<cst_key>2f9f6b6c-654d-480b-97d9-c485756cddab</cst_key>
<AfterMergeAction>Delete</AfterMergeAction>
</MergeCustomer>
</customersToMerge>
</MergeCustomers>
</soapenv:Body>
</soapenv:Envelope>

Request With Two Duplicate Customers

You can pass two or more MergeCustomer elements if you have more than one duplicate customer you wish to merge.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<AuthorizationToken>
<Token>**************</Token>
</AuthorizationToken>
</soapenv:Header>
<soapenv:Body>
<MergeCustomers>
<cst_key_keep>cec29726-4a26-4c07-9162-048020e42241</cst_key_keep>
<customersToMerge>
<!-- first customer to merge -->
<MergeCustomer>
<cst_key>2f9f6b6c-654d-480b-97d9-c485756cddab</cst_key>
<AfterMergeAction>Delete</AfterMergeAction>
</MergeCustomer>
<!-- second customer to merge -->
<MergeCustomer>
<cst_key>156C43CA-8681-4FD5-8CF0-CA2FFEB2B94B</cst_key>
<AfterMergeAction>Hide</AfterMergeAction>
</MergeCustomer>
</customersToMerge>
</MergeCustomers>
</soapenv:Body>
</soapenv:Envelope>

Request Specifying Specific Modules

To specify which Modules to merge, pass a list of Module elements in the Modules array in the MergeCustomer element:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<AuthorizationToken>
<Token>**************</Token>
</AuthorizationToken>
</soapenv:Header>
<soapenv:Body>
<MergeCustomers>
<cst_key_keep>cec29726-4a26-4c07-9162-048020e42241</cst_key_keep>
<customersToMerge>
<MergeCustomer>
<cst_key>2f9f6b6c-654d-480b-97d9-c485756cddab</cst_key>
<AfterMergeAction>Delete</AfterMergeAction>
<Modules>
<Module>Abstract</Module>
<Module>Accounting</Module>
<Module>Accreditation</Module>
<Module>Activities</Module>
<Module>Address</Module>
<Module>Advertising</Module>
<Module>Affiliations</Module>
<Module>Awards</Module>
<Module>Certification</Module>
<Module>Chapter</Module>
<Module>Client</Module>
<Module>Committees</Module>
<Module>Correspondence</Module>
<Module>Degrees</Module>
<Module>E-Commerce</Module>
<Module>E-Mail</Module>
<Module>Events</Module>
<Module>Exhibits</Module>
<Module>Fax</Module>
<Module>Fundraising</Module>
<Module>Issues</Module>
<Module>Job Bank</Module>
<Module>Mailing List</Module>
<Module>Membership</Module>
<Module>Messaging</Module>
<Module>Miscellaneous</Module>
<Module>Order Entry</Module>
<Module>Phone</Module>
<Module>Relationships</Module>
<Module>Subscriptions</Module>
<Module>Survey</Module>
<Module>Tasks</Module>
<Module>Voting</Module>
<Module>Web Site</Module>
</Modules>
</MergeCustomer>
</customersToMerge>
</MergeCustomers>
</soapenv:Body>
</soapenv:Envelope>

Sample Responses

There will be one MergeCustomerResult element for each MergeCustomer in the request.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<AuthorizationToken xmlns="http://tempuri.org/">
<Token>dhopkins;darryl</Token>
</AuthorizationToken>
</soap:Header>
<soap:Body>
<MergeCustomersResponse xmlns="http://tempuri.org/">
<MergeCustomersResult>
<cst_key_keep>cec29726-4a26-4c07-9162-048020e42241</cst_key_keep>
<CustomerResults>
<MergeCustomerResult>
<cst_key>2f9f6b6c-654d-480b-97d9-c485756cddab</cst_key>
<AfterMergeAction>Delete</AfterMergeAction>
<Status>Merged</Status>
<ModuleResults>
<ModuleResult>
<Module>Activities</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Abstract</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Accounting</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Accreditation</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Activities</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Address</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Affiliations</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Awards</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Certification</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Chapter</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Client</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Committees</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Correspondence</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Degrees</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>E-Commerce</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>E-Mail</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Events</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Exhibits</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Fax</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Fundraising</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Issues</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Job Bank</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Mailing List</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Membership</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Messaging</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Miscellaneous</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Order Entry</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Phone</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Relationships</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Subscriptions</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Survey</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Tasks</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Voting</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Web Site</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>Advertising</Module>
<Status>Merged</Status>
</ModuleResult>
<ModuleResult>
<Module>E-Mail</Module>
<Status>Merged</Status>
</ModuleResult>
</ModuleResults>
</MergeCustomerResult>
</CustomerResults>
</MergeCustomersResult>
</MergeCustomersResponse>
</soap:Body>
</soap:Envelope>

 

JSON Method

POST /xWeb/JSON/MergeCustomers


DATA: JSON
{
    "MergeCustomers " : {
        "cst_key_keep" : "{{indCstKeyMergeCustomersKeep}}",
        "customersToMerge" : [
            {
                "cst_key" : "{{indCstKeyMergeCustomersMergeA}}",
                "AfterMergeAction" : "Delete",
                "Modules" : [
                    {{mergeCustomerModules}}
                ]
            },
            {
                "cst_key" : "{{indCstKeyMergeCustomersMergeB}}",
                "AfterMergeAction" : "Delete",
                "Modules" : [
                    {{mergeCustomerModules}}
                ]
            }
        ]
    }
}

SAMPLE RESULT
HTTP STATUS: 200
DATA: JSON
{
    "cst_key_keep": "b473cc93-97eb-4a84-ae48-1e70eda8a27d",
    "CustomerResults": [
        {
            "cst_key": "5abea7c8-82db-49cc-9baa-38e67b57e336",
            "AfterMergeAction": 1,
            "Status": 0,
            "ModuleResults": [
                {
                    "Module": "Abstract",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Accounting",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Accreditation",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Activities",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Address",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Advertising",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Affiliations",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Awards",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Certification",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Chapter",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Client",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Committees",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Correspondence",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Degrees",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "E-Commerce",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "E-Mail",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Events",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Exhibits",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Fax",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Fundraising",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Issues",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Job Bank",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Mailing List",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Membership",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Messaging",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Miscellaneous",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Order Entry",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Phone",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Relationships",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Subscriptions",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Survey",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Tasks",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Voting",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Web Site",
                    "ErrorMessage": null,
                    "Status": 0
                }
            ]
        },
        {
            "cst_key": "c7c44740-35f7-4992-9faa-9493041547bd",
            "AfterMergeAction": 1,
            "Status": 0,
            "ModuleResults": [
                {
                    "Module": "Abstract",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Accounting",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Accreditation",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Activities",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Address",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Advertising",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Affiliations",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Awards",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Certification",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Chapter",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Client",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Committees",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Correspondence",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Degrees",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "E-Commerce",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "E-Mail",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Events",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Exhibits",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Fax",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Fundraising",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Issues",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Job Bank",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Mailing List",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Membership",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Messaging",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Miscellaneous",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Order Entry",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Phone",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Relationships",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Subscriptions",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Survey",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Tasks",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Voting",
                    "ErrorMessage": null,
                    "Status": 0
                },
                {
                    "Module": "Web Site",
                    "ErrorMessage": null,
                    "Status": 0
                }
            ]
        }
    ],
    "ErrorMessage": null
}

 

Related Web Methods

Related Functionality

Recommendations

Managing Errors

The Combine/Merge operation can produce errors if it attempts to delete a duplicate customer that still has data linked to that customer via a foreign key that has a relationship to the customer table (netFORUM observes classic data normalization and referential integrity). Ordinarily, the Combine/Merge operation should be able to handle this by swapping the duplicate customer key value for the “keep” customer key value, but failures can occur.

If a failure does occur, it can be possible to correct errors of the same scenario in a later Combine/Merge operation by adding Dedup Tables and before/after SQL scripts in the administrative interface of netFORUM. Work with the netFORUM customer to resolve these issues so subsequent combine/merge operations will be successful.

Additionally, be aware that the Combine/Merge operation runs each module merge in its own database transaction. A possible scenario is that the merges of the first 10 modules may succeed, but the 11th may fail. The failure of the 11th will not rollback or undo the first 10. Those are permanent. A user will need to address any issues that caused the 11th failure, and then try to merge again. It will most likely require careful editing or transferring of records to resolve the issue. After that, the Combine/Merge operation may start again. These exceptions will need to be handled carefully by staff in the staff interface (iWeb) and not in xWeb. Therefore, log failures from this method carefully and provide a way to get that information to staff people who can resolve them. Include both customer keys (and ideally other identifying information about the customer such as customer ID and name) and the error message.

Handled errors from the Combine/Merge operation run by this web method are contained in the response, not in an exception.

If an error is encountered in merging a module, then the mergers for that module are rolled back and the Combine/Merge process stops for that customer and any additional customers. Supposing that you have a “survivor” customer that you are trying to merge with two other customers, A and B. If A fails, then you might want to try to merge B separately from A. You might also try to merge A again, but omit the module that failed; in this case, specify the “Hide” option for the AfterMergeAction. You should also log this scenario for staff followup on the one module that failed.

As this section explains, merging customers is not always a smooth process. Therefore, if you are thinking of using this web method, be sure to add pessimistic error handling for the inevitable exceptions.

That being said, if the focus of your merging is on imported records from purchased lists that are unlikely to have a lot of data beyond basic CRM/rolodex data, then these types of records should merge easily without errors.

Searching for Duplicates

This method only merges customers you have identified as duplicates. This method does not find duplicates. You may use GetQuery or GetDynamicQuery to find customers and provide a user the ability to scan the data and identify duplicates.

Choosing the Duplicate and the Survivor

Does it matter which customer is the survivor and which is the duplicate who will be deleted?

It can be important.

From a technical perspective, the Combine/Merge process will have a higher likelihood of success if the “survivor” is the customer with more data; see Managing Errors for more on why this is.

From a culture perspective, if a customer is a member, they often have a member card and may know their member number. Therefore, you’d want to make sure the survivor customer still has that number after the merge.

A few considerations:

  • If one customer has a history of membership, and the other does not, then make the customer with the memberships be the survivor.
  • The customer with the earlier add date is probably the better candidate for being the survivor, unless the older record was imported ten years ago from a list and never touched since then.
  • If one customer has linked financial transactions and the other doesn’t, then the customer with the transactions should probably be the survivor.

C# Code Sample

The following C# code sample illustrates how to call this web method.

using System;
using System.Data;
using System.Xml;
using xWeb;
 
public partial class MergeCustomers : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Code below shows how to call the web method code
 
// Instantiate xWeb:
        ClientWebService xWeb = new ClientWebService();
 
 
// Get a list of all the Module/FileGroups in netFORUM if needed
        XmlNode modulesXml = null;
        modulesXml = xWeb.GetMergeCustomerModules();
 
// load the XML response into a DataSet for easier parsing:
        DataSet dataSetModules = PopulateDataSetFromXmlNode(modulesXml);
 
// this is the key of the customer that we want to keep:
        var cst_key_keep = new Guid("cec29726-4a26-4c07-9162-048020e42241");
 
// This will be a customer who should get merged into the customer-to-keep:
// You can add more than one customer-to-merge if needed.
// this customer will, if merged successfully, be Hidden or Deleted based on the setting of AfterMergeAction.
        var mergeCustomer = new xWeb.MergeCustomer();
        mergeCustomer.cst_key = new Guid("1c9d3319-890c-4104-bb58-c7a7b5c86fb6");
        mergeCustomer.AfterMergeAction = AfterMergeAction.Delete;
 
// We will choose to merge ALL modules, although you could choose to merge only certain modules:
// You can also leave the Modules array empty to indicate that you want to merge all modules:
string[] modules = new string[dataSetModules.Tables[1].Rows.Count];
int i = 0;
foreach (DataRow oRow in dataSetModules.Tables[1].Rows)
{
            modules[i] = oRow["Module"].ToString();
            i++;
}
        mergeCustomer.Modules = modules;
 
// Add the mergeCustomer to an array of MergeCustomer[] that we will pass to the MergeCustomers web method
        xWeb.MergeCustomer[] CustomersToMerge = new MergeCustomer[1];
        CustomersToMerge[0] = mergeCustomer;
 
// Call the MergeCustomers web method:
        xWeb.MergeCustomerResults results = xWeb.MergeCustomers(cst_key_keep, CustomersToMerge);
 
// examine the results from the method to see if it was successful, and to interpret the 
// results in case of a failure.
 
// this property MIGHT contain an error message, if any:
string szMessage = results.Message;
 
// the customer-key-to-keep you specified to the web method is echoed back in this property:
        var customer_key_to_keep = results.cst_key_keep;
 
// Loop through each customer and check the results for each of the customer(s) you attempted to merge:
foreach (xWeb.MergeCustomerResult mergeCustomerResult in results.CustomerResults)
{
// the customer key of the customer who was just merged is echoed back:
// Note that if the merge was successful and if you chose the Delete option for AfterMergeAction,
// then this customer key will no longer exist in netFORUM:
            var cst_key_who_was_merged = mergeCustomerResult.cst_key;
 
// The AfterMergeAction (Delete or Hide) you provided to the web method is echoed back:
            var afterMergeAction = mergeCustomerResult.AfterMergeAction;
 
switch (mergeCustomerResult.Status)
{
case MergeResult.Merged:
// this customer was merged successfully!
// if you get this result, you don't need to examine other properties--it's a success.
                    break;
 
case MergeResult.UnProcessed:
// the method did not even attempt to merge this customer;
// this could happen only if a previous custoemr failed to merge, which 
// stops the processing of any subsequent customers
                    break;
 
case MergeResult.Error:
// there was at least one error trying to merge this customer
// let's examine the results of each module to see where the error occurred:
foreach (xWeb.ModuleResult moduleResult in mergeCustomerResult.ModuleResults)
{
switch (moduleResult.Status)
{
case MergeResult.Merged:
// this module merged successfully for this particular Customer
                                break;
 
case MergeResult.UnProcessed:
// this module was not attempted to be merged for this particular Customer,
// because an earlier module 
// had produced an error, which stops the processing of any subsequent modules.
                                break;
 
case MergeResult.Error:
// this module produced the error when trying to merge the module for this customer.
// The ErrorMessage will be a technical error useful for diagnostics, but the end user won't be able to 
// "fix" it except in netFORUM iWeb.
 
string szErrorMessage = moduleResult.ErrorMessage;
 
// The particular module that failed to merge:
string szModuleName = moduleResult.Module;
                                break;
}
 
}
                    break;
}
}
}
 
public DataSet PopulateDataSetFromXmlNode(XmlNode xmlNode)
{
        XmlReader xmlReader = new XmlNodeReader(xmlNode);
        DataSet oDataSet = new DataSet();
        oDataSet.ReadXml(xmlReader, XmlReadMode.Auto);
return oDataSet;
}
}
Was this article helpful?
0 out of 0 found this helpful