Search code examples
netsuitesuitescriptsuiteql

How to get All the effective Currency exchange rate by date in NetSuite one time?


[![enter image description here][1]][1]

Any method to query All the effective Currency exchange rates by date in NetSuite one time? Just like the Field "AS OF" in the Currency Exchange Rates Page did.

I thought about the "N/curency" module and the https.get function, but it seems to be high cost, any tips or solution? [1]: https://i.sstatic.net/1KPMK.png


Solution

  • The table is exposed in SuiteTalk and the Analytics browser so you can get the values either way. Via Analytics/SuiteQL

    require(['N/query'], function(query) {
       var sql =
            "SELECT " +
            " cr.id, b.symbol as basecurrency, c.symbol as transactioncurrency,  cr.effectivedate, cr.exchangerate" +
            " FROM " +
            "  currencyrate as cr, currency as c, currency b where c.id = transactioncurrency and b.id = basecurrency and cr.effectivedate = '5/2/2022' ";
    
        var results = query.runSuiteQL({
            query: sql
        }).asMappedResults();
    
        console.log(results);
    });