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.1 Script Basics and SuiteScript 2.1 Script Types.

          /**
 * @NApiVersion 2.1
 */

require(['N/format'], (format) => {
    const formatToString = () => {
        const rawNum2 = -44444.44;
        // Format the number using the user's NetSuite preferences.
        return format.format({
            value: rawNum2,
            type: format.Type.FLOAT
        });
    };

    return { formatToString };
}); 

        

General Notices