2

To find duplicates of a custom object I planned using Salesforce.com's native Duplicate Management functionality. I was a bit disappointed to see that matching rules are not able to compare Long text field.

In my case CustomObject__c X and Y are equal if all of its 50 long text attributte fields are equal.

I thought of this workaround but am a bit afraid that this is a bit hacky, has bad performance and other drawbacks:

  1. Add a txt_Hashcode__c field to CustomObject__c
  2. Add BeforeInsert and BeforeUpdate trigger that uses the Apex Crypto class to create a hashcode out of the 50 long text fields and populate the field
  3. Add Duplicate rule that only checks for equality of this field.

What do you think?

2
  • 1
    Any reason you chose to use the after trigger rather than a before trigger? BTW, we've done something similar, but not for 50 long text fields! :) – Nick Cook Aug 30 '16 at 8:24
  • You are right a BEFORE trigger is better. I changed it. Can you elaborate more on a) what and how you did it and b) if you see any risks in doing it for 50 long text fields? – Robert Sösemann Aug 30 '16 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.