Provides an ability to override the standard Merge method with user defined method.
One practical example is implementing custom merge method in Apex and exposing it as a Salesforce REST.
Read more:
Exposing Apex Classes as REST Web Services | Apex Developer Guide | Salesforce Developer
@RestResource(urlMapping='/mergeAccounts/*')
global class accountMergeAPI {
@HttpPost
global static MyMergeResponse[] accountMerge(MyMergeRequest[] request) {
// implement custom merge
return new MyMergeResponse[] {resp};
}
global class MyMergeRequest{
public SObject masterRecord {get; set;}
public ID[] recordToMergeIds {get; set;}
public Map<String,String> AdditionalInformationMap {get;set;}
}
global class MyError {
public String statusCode {get; set;}
public String message {get; set;}
public String[] fields{get; set;}
}
global class MyMergeResponse {
public MyError[] errors {get; set;}
public ID id {get; set;}
public ID[] mergedRecordIds {get; set;}
public Boolean success {get; set;}
public ID[] updatedRelatedIds {get; set;}
}
}
In order to activate above REST service, specify the following Endpoint Url in the API Integration Merge method
<salesforce url>/services/apexrest/mergeAccounts/accountMerge
Below you can find complete example of overriding standard merge to solve an issue of orphaned households in Salesforce NPSP.