How to Export Excel Files from Suitelet using a Client Script

To directly export an Excel file to the user’s system upon clicking a button on the suitelet page, we can use the following method. Client script function: function exportExcel() { try { const filename = ‘fileName’; // Build up the XML string and set encoding for Excel xmlString = “; //added the xmlString of the… Continue reading How to Export Excel Files from Suitelet using a Client Script

Quantity available of a kit item in NetSuite using saved search

Since the available quantity cannot be directly fetched from a kit item record, a saved search is used to retrieve the available quantity of its member items and their respective quantities in the kit. The saved search below provides the available quantity of a kit item. This function returns an object where the kit item’s… Continue reading Quantity available of a kit item in NetSuite using saved search

SuiteQL query to fetch the item details based on a subsidiary

Since we are unable to directly filter the item data using the subsidiary, we will have to use a modified version of the item query by joining the itemSubsidiaryMap table and subsidiary table to get the required results. SELECT item.itemid,item.id,item.itemtype FROM itemSubsidiaryMap  INNER JOIN item ON  (item.id=itemSubsidiaryMap.item) INNER JOIN subsidiary ON  (subsidiary.ID=itemSubsidiaryMap.subsidiary) WHERE subsidiary.id=${nsSubsidiary}

GraphQL query to fetch all the inventory item details from Shopify

GraphQL query to retrieve all inventory items. Utilize afterCursor for pagination to fetch all orders, as each query instance can return a maximum of 250 orders.  query getInventoryItems($afterCursor: String) {                             inventoryItems(first: 250, after: $afterCursor) {            … Continue reading GraphQL query to fetch all the inventory item details from Shopify

How to Retrieve All Errors from Every Stage of a Map/Reduce Script in the Summarize Stage

To retrieve all the errors that occurred in different stages of a Map/Reduce script during the summarize stage, you can use the following code: if (summaryContext.inputSummary.error) {                     let error = JSON.parse(summaryContext.inputSummary.error);                     log.error(“Errors in getInputData”,error);  … Continue reading How to Retrieve All Errors from Every Stage of a Map/Reduce Script in the Summarize Stage

Overview of llm.generateText in SuiteScript 2.1

The llm.generateText() method in SuiteScript 2.1 enables server scripts to interact with large language models (LLMs) by generating text responses based on provided prompts. This functionality is part of the N/llm module, introduced in version 2024.1. Key Features Response Type: Returns an llm.Response object containing the generated text. Governance: Consumes 100 governance units per execution.… Continue reading Overview of llm.generateText in SuiteScript 2.1

How to differentiate item lines from shipping lines in transaction searches

To retrieve line-level values from a transaction record in a search and differentiate between item lines and shipping lines in the results, we can use the itemType value. For example: search.createColumn({                             name: “formulatext”,                … Continue reading How to differentiate item lines from shipping lines in transaction searches

SuiteScript Function to Convert NetSuite Invoice Records into CSV Format for R365 ERP

The SuiteScript function toCSV(invoiceId) generates a CSV file containing specific invoice data for a given invoice ID. It uses the search.create method to retrieve relevant transaction lines while filtering out any unnecessary data. function toCSV(invoiceId) {     try {         let filters = [             [“internalid”,… Continue reading SuiteScript Function to Convert NetSuite Invoice Records into CSV Format for R365 ERP