Ziva Yehudain
Ziva Yehudain

Reputation: 1

how to format phone numbers in crm 2013 plugin using QueryExpression

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

Upvotes: 0

Views: 129

Answers (1)

Guido Preite
Guido Preite

Reputation: 15128

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.

Upvotes: 2

Related Questions