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
naveenkumarbvnaveenkumarbv 

Unique Check for EmailId in Contact Entity

Hi All,

 

This may sound like a newbie question, I have started working on salesforce recently and a  bit stuck up on some implementations.

 

I am using the REST way to access salesforce - (OAuth2 to authenticate, and REST implementation to query Salesforce).

 

1. How do I impose a Unique Index constraint  on Email in CONTACT entity, basically I dont want to store duplicate email ids in Contact entities. How do we do it?

 

I have used Validation Rules to apply Mandatory Check on Email Column, but how do we impose a Unique Check.

 

2. Also, by default LastName in Contact entity is Mandatory. How to remove this mandatory check.

 

Can anyone help me regarding this?

 

Regards,

Naveen Kumar B.V

Best Answer chosen by Admin (Salesforce Developers) 
Ritesh AswaneyRitesh Aswaney

Create a hidden (not displayed on your page layout) Email__c custom field on Contact - mark this field as Unique (check the Unique checkbox in the field creation wizard)

Set up a workflowrule  on contact create / edit (as your business logic maybe), which invokes a field update action - which copies the Email from the default Email field to this custom field. The unique constraint check will return an error message if a duplicate email id is entered.

 

About the mandatory last name, don't reckon you can get rid of that (not via config anyway) - system constraint.

All Answers

Ritesh AswaneyRitesh Aswaney

Create a hidden (not displayed on your page layout) Email__c custom field on Contact - mark this field as Unique (check the Unique checkbox in the field creation wizard)

Set up a workflowrule  on contact create / edit (as your business logic maybe), which invokes a field update action - which copies the Email from the default Email field to this custom field. The unique constraint check will return an error message if a duplicate email id is entered.

 

About the mandatory last name, don't reckon you can get rid of that (not via config anyway) - system constraint.

This was selected as the best answer
naveenkumarbvnaveenkumarbv

Hi Ritesh,

 

Thanks for the reply :-) ,  it gave me some direction on moving forward. I will have to learn how to create workflow rules in salesforce now. Do we have any other way of doing it.

 

And regarding removing LastName mandatory check, I am planning on creating a new custom field (without a mandatory check).

But a little bit worried on performance issues, do we have any restrictions on the number of custom fields we create.

Or can you please suggest any other way of handling such issues.

Thanks once again.

 

Regards,

Naveen Kumar B.V

 

rahul tanejarahul taneja

It helped me 

Thanks!!!
sameerin khansameerin khan
Thank Rahul for the Link I had the same issue It helped me.

Thanks