Format a Number as a String

The following sample formats a raw number value (formatted according to the user’s preference) as a string using format.format(options).

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
 * @NApiVersion 2.x
 */

require(['N/format'], 
    function(format){
         function formatToString() {
              // Assume number format is 1.000.000,00 and negative format is (100)
              var rawNum2 =  -44444.44
              return format.format({value:rawNum2, type: format.Type.FLOAT}) 
              }
         var formattedNum2 = formatToString(); // "44.444,44" -- a string
   }); 

        

General Notices