Phone type

Phone type documentation.

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

NameSupported
Many multiplicityyes
Default valuesyes
Unique flagyes
Required flagyes
Indexable flagyes
Sensitive flagyes
Calculated valueyes
Automatic initializationno
Calculated initial valueno
Aggregationno
Default type rulesyes
Default display optionsno

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

OperatorSupported
equalsyes
notEqualsyes
emptyyes
notEmptyyes
likeyes
greateryes
greaterOrEqualsyes
lessyes
lessOrEqualsyes
betweenyes
currentUserFieldno

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

OperatorSupported
sumno
avgno
firstyes
lastyes
minyes
maxyes

UI queries

Please refer to the UI Queries Documentation for more detailed information.

Matching of values

PropertyDescription
Matching operatorlike

Available operators

OperatorSupported
Many valuesyes
Greaterno
Greater or equalsno
Lessyes
Less or equalsyes
Betweenno