Phone Number Formatter and Parser Objects in SuiteScript
Phone Number Formatter and Parser objects enable formatting and parsing of phone numbers in SuiteScript for client and server scripts.
TL;DR
The Phone Number Formatter and Parser objects in SuiteScript provide tools for formatting phone numbers into strings and parsing strings into phone number objects. This helps maintain consistency in phone number display across your NetSuite applications.
What are the Phone Number Formatter and Parser Objects?
The Phone Number Formatter and Phone Number Parser are key components provided by the format module in SuiteScript. They enable developers to manipulate phone numbers easily within their client and server scripts.
Phone Number Formatter
The format.PhoneNumberFormatter object is designed to format phone numbers into standardized string formats. This ensures that phone numbers are displayed consistently, which is essential for user interfaces and reporting.
Members of the Phone Number Formatter Object
| Name | Type | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
format.PhoneNumberFormatter | Object | Object | Client and server scripts | The object that formats the phone number to a string. |
PhoneNumberFormatter.format(options) | Method | string | Client and server scripts | Formats the phone number object to a string. |
format.PhoneNumberFormatType | Enum | enum | Client and server scripts | Holds values for phone number format types. |
format.Country | Enum | enum | Client and server scripts | Holds values for different countries, aiding in formatting. |
Phone Number Parser
The format.PhoneNumberParser object provides functionality to convert strings into phone number objects. This is particularly useful when input from users needs to be validated and formatted before being processed further.
Members of the Phone Number Parser Object
| Name | Type | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
format.PhoneNumberParser | Object | Object | Client and server scripts | The object that parses the string into a phone number. |
PhoneNumberParser.parse(options) | Method | Object of type PhoneNumber | Client and server scripts | Parses a string to create a phone number object. |
Code Example
Here’s a simple example demonstrating how to use the Phone Number Parser and Formatter objects:
1// Additional code ...2var origNumberStr = "602547854ext.154";3 4var pnParser = format.getPhoneNumberParser({5 defaultCountry: format.Country.CZECH_REPUBLIC6});7var phoneNumber = pnParser.parse({8 number: origNumberStr9});10 11var pnFormatter = format.getPhoneNumberFormatter({});12var strNumber = pnFormatter.format({13 number: phoneNumber14});15// expected output (strNumber) is '+420 602 547 854 ext. 154'16// Additional code ...Who Does This Affect?
- Developers: Enhance scripts that require phone number management and display.
- Administrators: Ensure phone numbers across the system meet formatting standards.
Key Takeaways
- The Phone Number Formatter and Parser objects streamline phone number formatting and parsing in SuiteScript, ensuring consistency and compliance.
- The objects support both client and server script types, making them versatile for various applications.
- Using enums for format types and country selections simplifies code and enhances readability.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
Are the Phone Number Formatter and Parser objects applicable to both client and server scripts?
Do I need to set a default country for parsing phone numbers?
How do the Phone Number Formatter and Parser handle extensions in phone numbers?
Does the format module in SuiteScript provide enums for country and phone number format types?
Was this article helpful?
More in General
- Payment Date Prediction Feature in NetSuite
Payment Date Prediction in NetSuite utilizes machine learning to enhance financial planning by predicting invoice payment dates.
- NetSuite Ship Central Enhancements for Packing & Shipping
NetSuite Ship Central features enhance packing and shipping operations for improved efficiency and accuracy.
- New Role Setup for NetSuite AI Connector Service in 2026.1
The 2026.1 release adds a new role requirement for the NetSuite AI Connector Service, streamlining custom tool development.
- Generative AI Features in NetSuite 2026.1
Discover new generative AI features in NetSuite 2026.1, enhancing reporting, search, predictions, and development productivity.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category