format.Type

Note:

JavaScript does not include an enumeration type. The SuiteScript 2.x documentation uses the term enumeration (or enum) to describe a plain JavaScript object with a flat, map-like structure. In this object, each key points to a read-only string value.

Enum Description

Holds the string values for the supported field types. Use this enum to set the value of the options.type parameter when calling format.format(options) or format.parse(options).

Module

N/format Module

Sibling Module Members

N/format Module Members

Since

2015.2

Values

Value

Value

Value

ADDRESS

EMAILS

POSCURRENCY

CCEXPDATE

FLOAT

POSFLOAT

CCNUMBER

FULLPHONE

POSINTEGER

CCVALIDFROM

FUNCTION

QUOTEDFUNCTION

CHECKBOX

FURIGANA

RADIO

CLOBTEXT

IDENTIFIER

RATE

COLOR

IDENTIFIERANYCASE

RATEHIGHPRECISION

CURRENCY

INTEGER

SELECT

CURRENCY2

MULTISELECT

TEXT

DATE

MMYYDATE

TEXTAREA

DATETIME

NONNEGCURRENCY

TIME

DATETIMETZ

NONNEGFLOAT

TIMEOFDAY

DOCUMENT

PACKAGE

TIMETRACK

DYNAMICPRECISION

PERCENT

URL

EMAIL

PHONE

Be aware of the following:

  • The following field types require a value of greater than 0:

    • POSCURRENCY

    • POSFLOAT

    • POSINTEGER

  • NONNEGFLOAT requires a value that is greater than or equal to 0

  • CURRENCY field type rounds the number based on the user's currency precision setting and is limited to hundredths / 2 decimals (0.00).

  • CURRENCY2 field type formats using a record’s currency precision.

  • If any of the following field types is set to hidden, the object returned is text.

    • CHECKBOX

    • RADIO

    • SEELCT

    • TEXTAREA

  • DYNAMICPRECISION is controlled by NetSuite and can differ from field to field.

Syntax

Important:

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

            //Run this sample in debugger to see how values are formatted.

...
require(['N/format'], function(format) {
    Object.getOwnPropertyNames(format.Type).forEach(function(type) {
        log.debug(type, format.format({
            value: 12345,
            type: format.Type[type]
        }));
        /*use any value instead of 12345 to see how is it formatted*/
    })
}) 

          
            // Add additional code
...
function formatTimeOfDay() {
              // Assume the time format is hh:mm (24 hours) 
              var now = new Date(); // Say it's 7:01PM right now.
              var formattedTime = format.format({value: now, type: format.Type.TIMEOFDAY})  
              });
        }
...
// Add additional code 

          
            require(['N/format'],
  function(format) {

  function parseAndFormatDateString()
{
   var rawDateString = "07/28/2015";
   var parsedDate= format.parse({
       value: rawDateString,
       type: format.Type.DATE
});
   console.log(parsedDate);
}

  parseAndFormatDateString();
}
); 

          

Related Topics

General Notices