Skip to content
Permalink
Browse files

Updates

  • Loading branch information...
Kyle Schmid
Kyle Schmid committed Jan 12, 2018
1 parent 02d27a3 commit c7381df243ea5d5fba82759a23a5fa4986bf9d28
Binary file not shown.
@@ -12,9 +12,9 @@ Object Merge is released under the open source BSD license. Contributions (code

### Unmangaged Package

You can go to one of the following URLs to install Object Merge as an unmanaged package:
* Production: https://login.salesforce.com/packaging/installPackage.apexp?p0=04t0H0000019nSt
* Sandbox: https://test.salesforce.com/packaging/installPackage.apexp?p0=04t0H0000019nSt
You can go to one of the following links to install Object Merge as an unmanaged package:
* <a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t0H0000019npT" target="_blank" >Production</a>
* <a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t0H0000019npT" target="_blank" >Sandbox</a>
### Ant/Force.com Migration Tool
You can fork this repository and deploy the unmanaged version of the code into a Salesforce org of your choice.
@@ -103,7 +103,15 @@ Once installed, you'll want to set up your first Object Merge Handler. To do so,
## Typical Use Cases
* While this tool doesn't identify duplicates, Salesforce has great standard features for doing so. You can run a report to get duplicate IDs and then use data loader with the Object Merge Pair object to merge duplicates en masse.
* While this tool doesn't identify duplicates, Salesforce has great standard features for doing so. You can run a report to get duplicate IDs and then use Data Loader with the Object Merge Pair object to merge duplicates en masse:
* Sort by Duplicate Record Set Name then in a manner to make your master records show up first
* Add columns for Master ID and Victim ID
* Copy the first ID to the Master ID field
* Use the Excel formulas in Example_Duplicate_Report.xlsx for the rest of the Master ID and Victim ID rows
* Copy/paste the Master ID and Victim ID columns into a new spreadsheet
* Sort by Victim ID and remove all rows with blank Victim IDs
* Save as a .csv
* Use Data Loader to insert these pairs into the Object Merge Pair object
* If you'd like to provide a more intuitive UI for your users to merge certain types of objects, you can leverage custom lookup fields, workflow field updates, and record types to remove the need for users to copy and paste Salesforce IDs. Example for Contact:
* Create "Master Contact" and "Victim Contact" lookups
* Create a "Contact Merge Pair" Page Layout
@@ -53,11 +53,11 @@ public class ObjectMergePairTriggerHandler {
if (Id.valueOf(p.Master_ID__c).getSobjectType() != Id.valueOf(p.Victim_ID__c).getSobjectType())
throw new ObjectMergePairException();

prefixes.add(String.valueOf(Id.valueOf(p.Master_ID__c)).substring(0, 3));

} catch (Exception e) {
addError(p, 'Invalid Master/Victim ID pair');
}

prefixes.add(String.valueOf(Id.valueOf(p.Master_ID__c)).substring(0, 3));
}

// Get prefix-name map
@@ -119,7 +119,7 @@ public class ObjectMergePairTriggerHandler {
}
}

// Method to perform merge of a list of pairs of the same object type
// Method to perform merge of a list of pairs of the same object type
private static void doMerge(List<Object_Merge_Pair__c> pairs, Object_Merge_Handler__c handler, Map<Id, List<Object_Merge_Field__c>> fields, Map<Id, List<Object_Merge_Field__c>> matchingFields) {

// Get set of parent record ids
@@ -342,6 +342,28 @@ private class ObjectMergePairTriggerHandlerTest {
System.assertEquals('Error performing DML', p1.Error_Reason__c);
}

@isTest
static void test_errors_4() {

Object_Merge_Pair__c p1 = new Object_Merge_Pair__c(Master_ID__c = 'test', Victim_ID__c = 'test');
Object_Merge_Pair__c p2 = new Object_Merge_Pair__c(Master_ID__c = 'test', Victim_ID__c = 'test');
insert new List<Object_Merge_Pair__c>{p1, p2};

p1.Status__c = 'Retry';
p1.Master_ID__c = p2.Id;
p1.Victim_ID__c = p1.Id;

Test.startTest();

update p1;

Test.stopTest();

p1 = [SELECT Id, Error_Reason__c FROM Object_Merge_Pair__c WHERE Id = :p1.Id];

System.assertEquals('Error performing DML', p1.Error_Reason__c);
}

@testSetup
static void setup() {

@@ -360,7 +382,8 @@ private class ObjectMergePairTriggerHandlerTest {
Object_Merge_Handler__c h1 = new Object_Merge_Handler__c(Name = 'Account', Active__c = true, RecordTypeId = pId);
insert h1;
Object_Merge_Handler__c h2 = new Object_Merge_Handler__c(Name = 'Contact', Active__c = true, Standard_Action__c = 'Delete Victim', RecordTypeId = cId, Child_Relationship_Name__c = 'Contacts', Object_Lookup_Field_API_Name__c = 'AccountId', Parent_Handler__c = h1.Id);
insert h2;
Object_Merge_Handler__c h3 = new Object_Merge_Handler__c(Name = 'Object_Merge_Pair__c', RecordTypeId = pId);
insert new List<Object_Merge_Handler__c>{h2, h3};

Object_Merge_Field__c f1 = new Object_Merge_Field__c(Name = 'Name', Use_for_Matching__c = false, Object_Merge_Handler__c = h1.Id, Active__c = true);
Object_Merge_Field__c f2 = new Object_Merge_Field__c(Name = 'Website', Use_for_Matching__c = false, Object_Merge_Handler__c = h1.Id, Active__c = true);

0 comments on commit c7381df

Please sign in to comment.
You can’t perform that action at this time.