format.getPhoneNumberFormatter(options)

Method Description

Creates a format.PhoneNumberFormatter object to format phone numbers to strings.

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.formatType

enum

required

Phone number format type. Must be a value from format.PhoneNumberFormatType.

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
... 
    // no parameter given so the default number formatter object returned which can be parsed
    var pnFormatter = format.getPhoneNumberFormatter();
    var strNumber = pnFormatter.format({
        number: phoneNumber
    });  // strNumber is '+420 602 547 854 ext. 154'

    // using the options/parameters
    var pnFormatter = format.getPhoneNumberFormatter({
        formatType: format.PhoneNumberFormatType.NATIONAL
    });
    var strNumber = pnFormatter.format({
        number: phoneNumber
    }); // strNumber is '(752) 410-5210 ext. 154'
...
// Add additional code 

          

Errors

Error Code

Thrown If

SSS_INVALID_FORMAT_TYPE

An invalid value is specified for the formatType option. Value must be a format.PhoneNumberFormatType value.

Related Topics

General Notices