format.getPhoneNumberParser(options)

Method Description

Parses a phone number from a string. Returns a format.PhoneNumberParser object.

Returns

Object

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/format/i18n Module

Methods and Properties

N/format/i18n Module Members

Since

2019.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.defaultCountry

enum

optional

Parser point of reference. Specify this value if the phone number is not in international formatl. If specified, value must be a format.Country value. If a value is not specified, the company country is used.

2020.2

Syntax

Important:

The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see N/format/i18n Module Script Samples.

            // Add additional code
... 
    var origNumberStr = "602547854ext.154";
    var pnParser = format.getPhoneNumberParser({
        defaultCountry: format.Country.CZECH_REPUBLIC
    });
    var phoneNumber = pnParser.parse({
        number: origNumberStr
    });

    /* phoneNumber.countryCode is '420'
       phoneNumber.extension is '154'
       phoneNumber.nationalNumber is '602547854'
       phoneNumber.numberofLeadingZeros is 1
       phoneNumber.carrierCode is ' '
       phoneNumber.rawInput is '602547854ext.154'
    */
...
// Add additional code 

          

Errors

Error Code

Thrown If

SSS_INVALID_COUNTRY_ID

An invalid value is specified for the defaultCountry parameter. Value must be a format.Country value.

Related Topics

General Notices