Fetch currencies using Suite Script 2.0

Things I want to do:

  1. I want to add currencies in Financial subtab when new customer / client gets created based on its Primary currencies.
  2. How should i fetch the currencies which are actually stored in NetSuite ->List->Accounting-> Currencies.
  3. And base on that currencies I need to append rest of the currencies excluding the default to customer record.
 function beforeSubmit(context) {
            var tgType = context.type;
            if(tgType == ‘create’) {
            var rec = context.newRecord;
            log.debug({title: ‘Record Type ‘, details: context.newRecord.type });
          const currencies = [‘CAD’,’EUR’,’USD’,’GBP’];
         // var currencies = [3,4,2,1];
            var cur = rec.getValue({
                fieldId: ‘currency’,
            });
            log.debug(“Currency:”,cur);
             var custCurrencyLines = rec.getLineCount({
            sublistId: “currency”
        });
          var cnt = 0;
            for (var key in currencies) {
                if (currencies[key] && cnt <=2) {
                    rec.insertLine({
                    sublistId: “currency”,
                    line: cnt
                    });
                    log.debug(“Count is”,cnt);
                    rec.setSublistText({
                    sublistId: “currency”,
                    fieldId: “currency”,
                    line: cnt,
                    text: currencies[key]
                    });
                    cnt++;
                }
            }
        }
    }
        return {
            beforeSubmit: beforeSubmit
        };

I want to fetch the currencies from NetSuite using suite script 2.0.

Rookie Asked on February 24, 2023 in SuiteScript.
Add Comment
2 Answer(s)

Hi,

You can search for currencies using the N/search module.

search.create({
   type: search.Type.CURRENCY,
   columns: ['internalid', 'name', 'symbol']
});

Thanks,

Chris

Intermediate Answered on February 24, 2023.
Add Comment

Thank you Chris.

Rookie Answered on February 24, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor