0

i'm developing a plugin (asp page) who should get as parameter Phone Number and retrieve the matched client in CRM 2013.

the phone number is clean from punctuation marks and spaces for example:

PhoneNum = Replace(PhoneNum, "-", "")
Dim query As New QueryExpression() With
         {
          .Distinct = False,
          .EntityName = "contact",
          .ColumnSet = New ColumnSet("contactid", "fullname")
         }
Dim queryCriteraFilter1 As New FilterExpression()
   queryCriteraFilter1.FilterOperator = LogicalOperator.Or
   queryCriteraFilter1.AddCondition(New ConditionExpression("telephone1", ConditionOperator.Like, {PhoneNum}))

My question is how to format the field telephone1 same as PhoneNum in order to match the exact record.

any help would be appreciated

A.L
  • 10,259
  • 10
  • 67
  • 98

1 Answers1

2

Phone number fields inside Dynamics CRM are stored as string.

If inside CRM they are stored like 0044-12345678 or 00441234 5678 you can't query them like "find phone numbers that are '004412345678' or contains 00441234.

The solution is to save all the phone numbers stored inside CRM in the same format (for example using a plugin) so after you can query them using a Like or Equal condition inside your QueryExpression.

Guido Preite
  • 14,905
  • 4
  • 36
  • 65