Phone type
On this page
Overview
This type can store a phone number, such as “111-222-3333
.” It’s also possible to store an international phone number if desired. In both cases, characters other than numbers are removed, and the phone number is automatically formatted for reading and display in the UI.
Available features
Name | Supported |
---|---|
Many multiplicity | yes |
Default values | yes |
Unique flag | yes |
Required flag | yes |
Indexable flag | yes |
Sensitive flag | yes |
Calculated value | yes |
Automatic initialization | no |
Calculated initial value | no |
Aggregation | no |
Default type rules | yes |
Default display options | no |
Type rules
International
Indicates whether the field supports international phone numbers. When enabled, validation becomes more flexible, allowing the entry of international phone numbers.
Default international prefix
If the field is set as international and the ‘+’ sign is not indicated at the beginning of the value, a default prefix will be automatically added.
REST API
Read format
The format is a simple string that is already formatted as a phone number:
"contactInformation": {
"phoneNumber": "1-702-845-9380"
}
Write format
To set the value, you should provide a string with the appropriate value:
"contactInformation": {
"phoneNumber": "1-702-845-9380"
}
You can omit fixed format:
"contactInformation": {
"phoneNumber": "17028459380"
}
JavaScript API
Read format
The val()
method within the wrapper will return a the formatted phone number (with dashes):
// this will print something like "phone number: 1-405-298-5885"
log('phone: '+record.field('contactInformation.phoneNumber').val());
Write format
You can input the phone number in various formats. However, please note that only the numbers will be retained, and any other characters will be discarded. The phone number will then be automatically formatted for reading. Here are some sample formats:
// all this lines are equivalent
record.field('contactInformation.phone').val('1-405-298-5885');
record.field('contactInformation.phone').val('+1-405-298-5885');
record.field('contactInformation.phone').val('14052985885');
Wrapper method:
format()
Returns the phone number formatted with dashes.
Returns
string
- The formatted phone number.
Samples
// logs the formatted phone number
var record = sys.data.findOne('contacts', {number: 1});
sys.logs.info(record.field('phoneNumber').format());
Export/Import
Export format
The export format is a string representation of the phone number, including dashes:
"phoneField1","phoneField2"
"111-222-3333","549-261-654-9862"
Import format
The import format is a string representation of the phone number, where dashes are optional:
"phoneField1","phoneField2"
"111-222-3333","549-261-654-9862"
Queries
For more information, please refer to the Query Language Documentation.
Available operators
Operator | Supported |
---|---|
equals | yes |
notEquals | yes |
empty | yes |
notEmpty | yes |
like | yes |
greater | yes |
greaterOrEquals | yes |
less | yes |
lessOrEquals | yes |
between | yes |
currentUserField | no |
Query formats
To perform queries, you should provide the phone number as a plain string. Please note that non-numerical characters will be removed before executing the query. For example:
// finds companies with contact phone number like '123'
var records_sample = sys.data.find('companies', {'contactInformation.phoneNumber': 'like(123)'});
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
log(records_sample.next().label());
}
// finds companies with contact phone number like '123'
var query_sample = sys.data.createQuery('companies')
.field('contactInformation.phoneNumber').like('123')
var records_sample = sys.data.find(query_sample);
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
log(records_sample.next().label());
}
// finds companies with contact phone number like '123'
GET /data/contacts?contactInformation.phoneNumber=like(123)
Aggregate queries
Please refer to the Aggregate Queries Documentation for more detailed information.
Available operators
Operator | Supported |
---|---|
sum | no |
avg | no |
first | yes |
last | yes |
min | yes |
max | yes |
UI queries
Please refer to the UI Queries Documentation for more detailed information.
Matching of values
Property | Description |
---|---|
Matching operator | like |
Available operators
Operator | Supported |
---|---|
Many values | yes |
Greater | no |
Greater or equals | no |
Less | yes |
Less or equals | yes |
Between | no |