N/cache Module

Use the N/cache module to enable temporary, short-term storage of data. Using a cache improves performance by eliminating the need for scripts to repeatedly retrieve the same piece of data. You can use this module to build a cache to store and retrieve string values using a specific key. You can create a cache that… Continue reading N/cache Module

Browser Extensions

NetSuite: Show Field IDs This helpful extension will allow you to instantly locate a field on a NetSuite record. Simply type, CTRL + SHIFT + F to locate the field by the internal ID. Use CTRL + SHIFT + L to find a field by the label. This will even work across different tabs and… Continue reading Browser Extensions

Workflow action script to validate filenames

Workflow action script to validate filenames uploaded under file tab is in correct format ‘Estimate_PO_1236’ and ‘Invoice_PO_1236’ define([‘N/error’, ‘N/file’, ‘N/record’, ‘N/search’, ‘N/runtime’],     /**  * @param{error} error  * @param{file} file  * @param{record} record  * @param{search} search  * @param{runtime} runtime  */     (error, file, record, search, runtime) => {         “use… Continue reading Workflow action script to validate filenames

Function to get Exchange rate using SuiteScript

function getExchangeRate(baseCurrency, sourceCurrency) { try { let exchangeRate = 0; let currencyrateSearchObj = search.create({ type: search.Type.CURRENCY_RATE, filters: [ [“basecurrency”, “anyof”, baseCurrency], “AND”, [“transactioncurrency”, “anyof”, sourceCurrency] ], columns: [ search.createColumn({ name: ‘internalid’, sort: search.Sort.DESC }), search.createColumn({ name: ‘effectivedate’, sort: search.Sort.DESC }), search.createColumn({ name: “exchangerate”, label: “Exchange Rate”, }), ] }); currencyrateSearchObj.run().each(function (result) { exchangeRate = result.getValue({… Continue reading Function to get Exchange rate using SuiteScript

TO LOAD A HTML FILE IN SUITELET

the code sample is used to load the html content in suitelet.  let htmlFile = file.load({               id: constants.filePaths.UPDATE_SO_PAGE_HTML             });             let htmlContent = htmlFile.getContents();             htmlContent = htmlContent               .replace(/${fullFileUrl}/g, fullFileUrl)               .replace(/${backgroundFileUrl}/g, backgroundFileUrl)               .replace(/${urlUpdateSO}/g, urlUpdateSO)             scriptContext.response.write(htmlContent);           } The code will load the html page. The replace function is used to replace with the contents in the netsuite.