format.Type

Note:

The content in this help topic pertains to SuiteScript 2.0.

Note:

JavaScript does not include an enumeration type. The SuiteScript 2.0 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).

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types

Module

N/format Module

Since

2015.2

Values

  • ADDRESS

  • CCEXPDATE

  • CCNUMBER

  • CCVALIDFROM

  • CHECKBOX

  • CLOBTEXT

  • COLOR

  • CURRENCY

  • CURRENCY2

  • DATE

  • DATETIME

  • DATETIMETZ

  • DOCUMENT

  • DYNAMICPRECISION

  • EMAIL

  • EMAILS

  • FLOAT

  • FULLPHONE

  • FUNCTION

  • FURIGANA

  • IDENTIFIER

  • IDENTIFIERANYCASE

  • INTEGER

  • MULTISELECT

  • MMYYDATE

  • NONNEGCURRENCY

  • NONNEGFLOAT

  • PACKAGE

  • PERCENT

  • PHONE

  • POSCURRENCY

  • POSFLOAT

  • POSINTEGER

  • QUOTEDFUNCTION

  • RADIO

  • RATE

  • RATEHIGHPRECISION

  • SELECT

  • TEXT

  • TEXTAREA

  • TIME

  • TIMEOFDAY

  • TIMETRACK

  • URL

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

N/format Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices