+ Start a Discussion
John Manager Training DepJohn Manager Training Dep 

Validation rule on a standard object to check if the combination for field A and B already exists?

Hi Team,

I have a requirement where the new case should not be created if field A(Contact ID lookup field) & field B(custom text field) combination already exists.
Is this possible to achieve the requirement using validation rule?

I know for a fact that as on date, VLOOKUP cannot be used on standard objects.

Any constructive suggestions are much appreciated!

Thanks!
AbhimanyuAbhimanyu
Hi John,

You need to create a new Field say A_concat_B__c and make sure you mark it unique.
Via workflow or Processbuilder update that field value with A+B.

Mark it the best answer if it helped
 
John Manager Training DepJohn Manager Training Dep
Sorry, but I missed another condition. The duplicate value(combination of field A and field B) should not be allowed when field C "is blank" or "is null".
If there is a value in field C, duplicate combination of field A and field B is allowed.

Any constructive suggession is greatly appreciated.
AbhimanyuAbhimanyu
Write Process Builder or WorkFlow Like this
IF ISBLANK( C ) 
THEN: A_concat_B__c  = A + B 
ELSE: A_concat_B__c = A + B + RecordId ( WIll make it unique automatically if C is not blank)
 
 
John Manager Training DepJohn Manager Training Dep
Thanks. When duplicate record is tried to save in the A_concat_B__c, it give an email with process builder error message, and a long message on the record creation/update screen.
Is it possible to change the text of error message displayed by process builder when duplicate scenario is identified?
AbhimanyuAbhimanyu
I am afraid if you need custom error then you have to write code in the trigger for this, if you want to avoid error email, you can write workflow.
AbhimanyuAbhimanyu
You can create Duplicate Rule and Matching Rule
https://trailhead.salesforce.com/content/learn/modules/sales_admin_duplicate_management/sales_admin_duplicate_management_unit_2
John Manager Training DepJohn Manager Training Dep
Duplicate and matching rule cannot be created on Case object.