Contact Us

Why Load Multiple Types of NetSuite Transaction Records?

When you're working with SuiteScript, you may run into situations where you are running a transaction search for records and need to load those records, but don't know the type of each specific record. The code blocks included below are useful if you are processing multiple types of transactions, and you need the specific record.Type for each type of transaction that you are working on.

Load NetSuite Transaction Records Step-by-Step

  1. Get a list of all the specific types of transactions your script will be processing.
  2. Create a transaction mapping object, mapping the internal NetSuite transaction type code to the correct record.Type value.

Below is an example:

const TRANSACTION_MAPPING = { "VendBill": record.Type.VENDOR_BILL, "ItemRcpt": record.Type.ITEM_RECEIPT, "Journal": record.Type.JOURNAL_ENTRY, "CashSale": record.Type.CASH_SALE, "CashRfnd": record.Type.CASH_REFUND, "CustInvc": record.Type.INVOICE, "InvAdjst": record.Type.INVENTORY_ADJUSTMENT, "Check": record.Type.CHECK };

3. Add the record type as a search column, as such below:

search.createColumn({name: "type", label: "Type"})

4. When loading each record, use result.getValue(“type”) with your transaction mapping to get the correct record.Type loaded.

This is how it would look:

const transactionRecord = record.load({ type: TRANSACTION_MAPPING[result.getValue("type")], id: result.getValue("internalid") });

Benefit from Loading Multiple Types of Transaction Records in NetSuite

That's it! You now have a unified approach to dynamically load multiple transaction types in SuiteScript—whether you're working with Sales Orders, Invoices, or any other record in NetSuite. By abstracting the record-loading step into a reusable function, you cut down on repetitive code and simplify future enhancements. Next time you need to support a new transaction type or adjust your logic, your script is already structured to handle it. Happy scripting!

Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!

Tagged with Training