Notifications

133 views

Description

Description

There are two field types: "Phone Number" and "Phone Number (E164)" to use phone numbers on the platform.

"Phone Number" is a legacy data type which inherits from String whereas "Phone Number (E164)" is the newer data type which provides richer functionalities and supports phone numbers in multiple country codes. We suggest users use the newer data type whenever they want to add a custom phone number field in a table.

Based on business requirement users may want to show the phone number in their local format in the instance.

Procedure

For the old "Phone Number" data type

The phone number format for this field is controlled by a client script. By default, it only supports phone number in local format for some western countries.

Follow these steps to customize this script to show phone number in a local format of your own country.

For example, users in Japan enter "334561234" in the field and hope it will be converted to "(03) 3456-1234" in Japan local format automatically.

Steps:

  1. Navigate to the sys_ui_script.list table
  2. Create a new UI script record with this information:
    • API Name = formatting.js (Or any preferred name)
    • UI Type = Desktop
    • Active = true
  3. Open this client script copy it into the newly created record:
    • https://<instance-name>.service-now.com/scripts/formatting.js
  4. Modify line 16 in the script as follows:
    • from: else if (n == 3)
    • to: else if (n == 2)
  5. Save the UI script record

 

For the new "Phone Number (E164)" data type

The phone number format for this data type is controlled by system property "glide.phone_number_e164.display_national".

This system property provides 3 values, all, user and false, to control the phone number format.

  • false: the system does not display phone numbers in local format (phone number will be displayed with a country code in the front)
  • all: the system always displays phone numbers in a local format no matter which country is selected
  • user: the system only displays phones number in a local format when the local settings of the currently logged-in user match the country that is selected in the country list of this "Phone Number (E164)" field.

Note: The local settings of the current user means the "Location" field in the sys_user table, not the country code and language fields in the users' profile.

Additional Information

If users apply the solution in formatting.js for the old "Phone Number" field, please be aware that users need to own that code from now on as it has been customized.

For more detailed information: E.164 phone number field configuration

Article Information

Last Updated:2019-08-02 20:38:42
Published:2019-07-04