QUESTION:
I am trying to enable or disable a non-standard or Custom object in DupeBlocker Settings but keep getting an Unexpected Error, how can I resolve?
ANSWER:
There are 2 reasons this can happen:
1. Your custom unit tests are completing with errors.
When DupeBlocker enables an object all the unit tests in your default namespace (those outside managed packages) are executed. If any fail, then enabling the object will fail. To check for unit test failures go to Setup->Develop->Apex Test Execution and run the unit tests under "My Namespace". If any errors are found those have to be fixed before enabling an object for DupeBlocker.
The long error message you receive when enabling the object in DupeBlocker will have the errors noted there also. You can search for "<failures>" to find them.
2. There is a unique constraint on a field in the custom object you are trying to enable. When searching the long error message for <failures> you will see something like this:
<failures><id>01p70000000PqvwAAC</id><message>System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: {uniquefieldname}__c duplicates value on record with id: 0067000000ZaDZD: []</message><methodName>testTrigger</methodName><name>DB_Custom_Opportunity</name><namespace xsi:nil="true"
When DupeBlocker enables an object it creates a custom class for that object which requires auto-generated unit tests for code coverage requirements. By default, data from an existing record is copied and used as test data for that unit test. As a result, the test will fail when it attempts to test an insert due to duplicate data in the unique field. To overcome this problem you will have to create a custom unit test data generator for that object such that it will use the test data you supply vs. copying data from an existing record.
More information on how to create your own unit test data including sample code can be found here.
NOTE: The sample codes cover data generators for accounts, contact, and leads, but you can remove those generators and just have one for the object type or types you wish to support.