function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alexander Svyatetskyi 6Alexander Svyatetskyi 6 

Unique combination of fields

Hi, I have two customer fields in Custom Object:

- Representative - lookup to User object
 - Customer – lookup to Contacts object

Need to do that pair of Representative+Customer will be unique. I create unique text field and add workflow rules that any insert or update will add to text field by formula: Representative__r.Id & Customer.Id.
Every time when I add or edit record with the same Representative or Customer display error : 

"Error: Invalid Data. 
Review all error messages below to correct your data.
Duplicate value on record: TC-0032 (Related field: UniqueTextField)"
I no need that Representative wiil be unique or Customer separately. I need to a unique couple of these values.
How to fix it?
 
Santosh Kumar 275Santosh Kumar 275
Hi, What is the evaluation criteria you are selecting?.
Looking at the error I feel you are selecting "Created and Edited everytime" instead of that you should select "created, and any time it’s edited to subsequently meet criteria
Try this hope this will work..
If this answer serve your purpose then Mayk this is as best ans.
Alexander Svyatetskyi 6Alexander Svyatetskyi 6
Hi, Santosh. I selected "created, and any time it’s edited to subsequently meet criteria" and select criteria are met Target Customer : Representative not equals NULL (Target Customer : Customer  not display). And any way display this error. 
Pun!5h3rPun!5h3r
Hi Santosh,

Instead Use Duplicate Rule, and in matching rule specify Representative AND Customer

Thanks and Regards