Handle Different Phone Formats in a Data Action

Could someone from your team assist me with a data query issue? In our Salesforce account object, I have one record with the phone number "123-456-7899" and another with "1234567899". When I pass "1234567899" to the data query, I need it to retrieve both records, regardless of whether the phone number includes dashes. I want the data action to fail because it retrieves two records, whereas it should bring both corresponding entries. My current data action only retrieves the record without dashes when I enter "1234567899". I attempted modifying the JSON to use FIND and $msdynamics.fieldSearchFilter, but I could not get the syntax right. The field "PrimaryPhoneNumber__c" is of type Phone. Below you find how I have it setup in my data action. Can you provide some guidance on how I can search against different phone standards?

Data Action Setup:

Configuration
Request

{
"requestUrlTemplate": "/services/data/v37.0/query/?q=$esc.url("SELECT account.Account_18_digit_ID__c, account.Name, account.CCR_ACN__c, account.FS_Market_ID__c, account.CCR_Bus_Type__c, account.CCR_Customer_Street__c, account.CCR_Customer_City__c, account.CCR_Customer_State_Province__c, account.CCR_Customer_Zip_Postal_Code__c, account.CCR_Customer_Country__c, account.OperatingHours__c, account.PhoneFormula_Tech__c FROM Contact WHERE PrimaryPhoneNumber__c = '$salesforce.escReserved(${input.PHONE_NUMBER})'")",
"requestType": "GET",
"headers": {
"UserAgent": "PureCloudIntegrations/1.0"
},
"requestTemplate": "${input.rawRequest}"
}

Response

{
"translationMap": {
"account": "$.records[*].Account"
},
"translationMapDefaults": {},
"successTemplate": "${account}"
}

I haven't had to dig into salesforce queries for a while, so I don't know the answer. The way I would approach it is to google your question, and work out the details in Workbench. I find tools like workbench or postman are better places to do debugging / exploration work. Once I know exactly what I need to do, making the data action is pretty straightforward.

--Jason

Thanks Jason. I tried using those and even chatGPT and have not been able to get it to work.

Maybe you could replace "-" with "" as described here:

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.