Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Search by not formatted number

rocio4
Kilo Explorer

Hi! I am trying to find a contact record in servicenow by phone number using their REST Api. Sample request:

https://your_domain/api/now/contact?sysparm_query=mobile_phoneLIKE512^mobile_phoneLIKE757^mobile_phoneLIKE6000

In the CRM record looks like this:

(512) 757-6000
 
Phone field is formatted this way, but, there is no limitation on how it can be saved/formatted. It can be something like this (512) 757 6000 or this 512-757-6000I don't have limit on formatting of this field.
 
So, I wanted to know if there´s a way to improve this query by using wildcards. I tried using:
https://your_domain/api/now/contact?sysparm_query=mobile_phoneLIKE*512*757*6000 
 
But this doesn´t works.

So, my question id: Is there some way to find "randomly" formatted phone number in sysparm_query? Wildcards? Filters? Filter functions?

 
1 REPLY 1

User367608
Tera Expert

Hi Rocio,

 

If the field is of type phone number it always sets to (XXX) XXX-XXXX format irrespective of how you enter and as long as it is 10 digit. If the user saves the record with '+' at the front then it saves with no formatting like +1XXXXXXXXXX. In your sysparm_query you can update the user input with (XXX) XXX-XXXX and +1XXXX and try to query the table with OR condition and that should return the results.