+ Start a Discussion
User UsersUser Users 

Finding a contact by phone number

Hi All,

I am trying find a contact by phone number.

I'm able to find a Contact whose phone# is exactly xxxxxxxxxx or something like +xxxxxxxxxx but it can't match numbers like:

91xxxxxxxxxx(Start with country code)

xxx-xxx-xxxx

(xxx)  yyy - zzzz(multiple embedded blanks)

So, in case the phone number is not stored in correct format, the contact is not found even though the phone number is basically the same.
DeveloperSudDeveloperSud
Hi ,

Did you try with 'LIKE' in your query string.As I have checked your requirement in my dev org it seems we can use like operator for your requirement for query out those contacts with phone numbers like +91********** or (415) ***-****.

Query it like below : select name ,phone from contact where phone LIKE '+91%' 
                              select name ,phone from contact where phone LIKE '(415)%' 
Ilayaraja PonnusamyIlayaraja Ponnusamy

Hi,
I'm also facing simillar issue while searching from pre chat page.
I'm searching the recod in the following ways.
1)            <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Lead" value="Phone,true;" />
2)            <input type="hidden" name="liveagent.prechat.query:ContactPhone" value="Contact,Contact.Phone" />

I'm able to find a Contact whose phone# is exactly xxxxxxxxxx but it can't match numbers like:

xxx-xxx-xxxx

(xxx)  yyy - zzzz(multiple embedded blanks)

So, in case the phone number is not stored in correct format, the contact is not found even though the phone number is basically the same.

ShikibuShikibu
I suggest that you make another field, calculated, and have that field contain all the digits in the phone number, with spaces, hyphens, plus signs, parens, etc. removed. Call it, for instance, Standardized_Phone__c. For instance, if Phone contains "+1 (800) 555-1212", Standardized_Phone__c would contain "18005551212".

Then search on "Standardized_Phone__c Like '%5551212%".