I want a trigger which gives error while creating a record in contact which does not allow duplicate values for phone field
-
possible duplicate salesforce.stackexchange.com/questions/25563/…– JaredTCommented Apr 6, 2016 at 13:57
-
Basically in contact object, i created one record with phone=123456789. If i create one more record with phone=123456789, then error has to come like 'duplicate values not allowed'– KS KumaarCommented Apr 6, 2016 at 13:59
-
If you can provide us with the code that you have currently tried, the steps you have taken and where you are stuck it would be helpful (and more likely to get an answer from the community).– Mark KeatsCommented Apr 6, 2016 at 14:09
Add a comment
|
1 Answer
Instead of going in trigger route, i would do the following.
- Create a text field which unique box checked.
- Create a workflow/process builder to execute on create.
- Create a field update/update action to Update the text field with Phone field.
After this if you create a record with phone 1234567890 and create another records with same phone, it will throw error with the link to the record which have this phone value.
Please refer this URL for more information.
If you still want to learn how to do this using trigger refer here.
Hope it helps.