How to format Currency In SuiteScript 2.0?

Hi All,

Netsuite provide a built in feature to format currency,
Lets say you have a number like 100000.12 and want to show it in USD currency format
($1,00,000.12) then this post will help you.

Netsuite have Currency Module also but we have to use N/format/i18n module for this purpose.
You should also check N/format module for other type of change in numbers.

i18n have a method called getCurrencyFormatter(..)  which return object in desired currency format.
In Example below we are using USD but you can choose any currency you want and have in Netsuite system.

function makeItCurrency(myNumber)
    {
      

        var myFormat = formati.getCurrencyFormatter({currency: "USD"});
        var newCur = myFormat.format({
                number: myNumber
                });
       
        return newCur;
    }
//formati is param for i18n
Don't forget to add  N/format/i18n module in your code.
Point to note: If you tofixed value and then pass into format(..) method, it will throw error.
Don't format it, netsuite will automatically format and return value.

Let us know if you got issue while using this API.


Thanks

Abhi


Note:  Currency formatting is handled by the format module and not the currency module.

Comments

  1. Shivalix Forex offers impressive currency exchange and remittance services with competitive live rates, fast delivery, and expert support for travelers and students.
    HTML a href Attribute
    currency exchange rates India
    forex remittance services in India
    zero fee forex card India
    foreign currency doorstep delivery in India

    ReplyDelete

Post a Comment

Thanks for you message, please join us on Facebook and Linkedin