Combinations of fields to be unique

I have a custom object. I want to put in a business rule so that a combination of two fields must be unique.

So I have Field1 and Field2 and want the combination to be unique:

Field1=4, Field2=7
Field1=4, Field2=8

is ok


Field1=4, Field2=7
Field1=4, Field2=7

is not ok

What is the easiest / best way to do this?


The easiest way to do this is to create a Unique Text field. Then, concatenate the values of the two fields together and update your Unique Text Field with the resulting value using a Workflow Field Update or a before Trigger.

Smashing the two fields together would essentially create a composite key that can be used to verify uniqueness.

Source : Link , Question Author : dublintech , Answer Author : Kevin O’Hara

Leave a Comment