Snippet to create a delay in a server side script

function setTimeout(aFunction, milliseconds){ var date = new Date(); date.setMilliseconds(date.getMilliseconds() + milliseconds); while(new Date() < date){ } return aFunction(); } And Then Call it like this: setTimeout(function(){ log.debug(‘Ran after 1 second’); }, 1000); By incorporating this function into your code, you can simulate a delayed execution of a specified function after a given time period. However,… Continue reading Snippet to create a delay in a server side script

How to Get Price Changes Using Saved Search and SuiteQL Queries in NetSuite

This article explains how to retrieve price level mappings and fetch price change details for inventory items using a combination of saved search and SuiteQL queries in SuiteScript 2.x. The approach compares pricing records of different versions to highlight pricing updates. Overview of Key Functions getPricelevel() Retrieves all price levels from NetSuite pricelevel record type… Continue reading How to Get Price Changes Using Saved Search and SuiteQL Queries in NetSuite

Removing Empty Values and Duplicates

When working with arrays in JavaScript, it’s common to encounter duplicate values and empty strings that clutter the data. By using the filter() method to remove empty entries and the Set object to ensure uniqueness, developers can quickly clean up arrays. This approach results in a simplified collection of distinct, non-empty values, improving both data… Continue reading Removing Empty Values and Duplicates

SuiteScipt 2.x User Event Script INVALID_API_USAGE

When creating a new record and testing a script, you may encounter the following error: INVALID_API_USAGE – Invalid API usage. You must use getSublistValue to return the value set with setSublistValue. This error typically occurs when using getSublistText() in situations where NetSuite expects getSublistValue(). Solution: Switch to getSublistValue One effective fix is to replace getSublistText()… Continue reading SuiteScipt 2.x User Event Script INVALID_API_USAGE

Extracting and Attaching Files from an External API to NetSuite Transactions

This guide outlines a basic script for integrating with an external API to download bill files (images/PDFs) and attach them to the related transactions in NetSuite. The script can be adapted for various projects that involve downloading and processing files linked to transactions, such as receipts, invoices, or reimbursements. The script saves the downloaded files… Continue reading Extracting and Attaching Files from an External API to NetSuite Transactions

Generating QR Codes for Suitelet External Links in NetSuite

Overview NetSuite does not provide a native QR code generator, but you can easily implement one using a Suitelet and a free QR code API. This approach is useful for mobile access to Suitelets by scanning QR codes instead of typing URLs. Solution Approach We will: Create a Suitelet that displays multiple external links. Dynamically… Continue reading Generating QR Codes for Suitelet External Links in NetSuite

HTTPS.requestSuitelet

The method https.requestSuitelet(options) sends an HTTPS request to another Suitelet (i.e., a script deployed as type “Suitelet”) within the same NetSuite account, and returns a ClientResponse object. Key facts: It is part of the N/https module and can be executed from client and server scripts (for example a Client script, UserEvent script, Suitelet etc). The… Continue reading HTTPS.requestSuitelet

Suitelet for Approval Workflows in NetSuite

What Is It? A Suitelet-based approval workflow is a custom-built interface that allows users to view, approve, reject, or comment on records pending approval. Unlike standard NetSuite workflows, Suitelets offer full control over layout, logic, and user experience.  Key Features Custom Dashboard: Display records awaiting approval with filters (e.g., by department, date, amount). Approval Actions:… Continue reading Suitelet for Approval Workflows in NetSuite

REST API for updating an RMA by PATCH method

Scenario: if a user needs to update the RMA record, we can use the method ‘PATCH’ in RESTLET. Method: PATCH End point URL: https://[account id].suitetalk.api.netsuite.com/services/rest/record/v1/returnAuthorization/[RMA record id] sample: https://123456-sb1.suitetalk.api.netsuite.com/services/rest/record/v1/returnAuthorization/123 Request body: {     “item”: {         “items”: [             {            … Continue reading REST API for updating an RMA by PATCH method