1

i want to make phone field unique for this i have tried triggers but i want to write validation rule for this i have written something like

AND( 
CONTAINS( 
VLOOKUP( 
$ObjectType.Student_Information__c.Fields.Phone_no__c, 
$ObjectType.Student_Information__c.Fields.Phone_no__c, Phone_no__c
), 
Phone_no__c
), 
OR( 
ISNEW(), ISCHANGED(Phone_no__c) 
) 
)

vlookup is not working for phone type field can you please help me with this,

is there any idea that i can make phone field unique ?

  • 2
    How is it not working? Does it not compile? Fail to validate? Can you show an example? Why are you not just using a Unique Index? Please edit your question to provide as much information as you can. – sfdcfox Feb 4 '19 at 5:00
1

Did you try with Unique checkbox on the field?

https://help.salesforce.com/articleView?id=custom_field_attributes.htm&type=5

| improve this answer | |
  • The unique attribute is unfortunately not supported for fields of the data type "phone". – Miichi Feb 4 '19 at 9:08
1

Have you considered using duplicate management (i.e., create a matching rule and a duplicate rule) instead of a validation rule? IMHO that feels better for phone numnbers since it would also allow you to change the behavior easily from completely blocking the creation of a new record with a non-unique phone number to just warning the user about a possible duplicate and leaving the choice on how to proceed to the user. After all, phone numbers might not be fully unique (esp. if land lines are included or if you consider a long duration where a cell number might be reassigned to a different subscriber).

Since you can't use VLOOKUP or the unique attribute on data fields of type phone, another option would be to change the data type to text -- but keep in mind that you loose the default functionality of a phone field with this (e.g., you'd have to create a validation rule with REGEX to enforce the format to a legal phone number).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.