The first step is to identify a field or set of field to determine the uniqueness of the record. Each business can define this uniqueness rule differently.
Let us consider “Last Name” as a field to be unique to a contact.
This standard salesforce field “Last Name” is mandatory.
Let us create a custom field of data type – Text with option – “Unique”
Let us create a workflow rule(WFR) for the duplicate check.
Go to Setup -> Create -> Workflow & Approvals -> Workflow Rules
Click on “New Rule”.
Select the object on which WFR needs to be added. In this case – “Contact”
Now set the rule as explained below,
Now let us specify Workflow Actions,
Under Immediate Action – select “New Field Update”,
Now save. Activate the WFR.
Now we are all set with WFR. Let us see how it works now. I have an existing contact with the last name of Prabha.
Let us try adding another contact with Last name PRABHA.
It applies the WFR and stops user from entering duplicate contact names. Here, the unique custom field we added in the beginning is made invisible, as I did not want on the page layout. Hence the error message mentions Hidden Field Value. However there are ways to customize error messages and make it more intuitive like “Contact already exists. Please re-check”.
Also, more than one field can be used to build the WFR to validate the uniqueness, using a concatenate formula to validate against (firstname&lastname for example).
Written by Prabha Krishnamurthy