Loading Multiple Types of Item Records (NetSuite SuiteScript)

in , October 28th, 2024

It is often the situation that you will need to work with many types of NetSuite item records, often without being given the specific type of item record beforehand. The following code blocks should provide an intuitive solution on how to process multiple types of item records.

1. const ITEM_MAPPING

Somewhere in your function, initialize this object:

const ITEM_MAPPING = {
  "Assembly": record.Type.ASSEMBLY_ITEM,
  "Description": record.Type.DESCRIPTION_ITEM,
  "Discount": record.Type.DISCOUNT_ITEM,
  "GiftCert": record.Type.GIFT_CERTIFICATE_ITEM,
  "InvtPart": record.Type.INVENTORY_ITEM,
  "Group": record.Type.ITEM_GROUP,
  "Kit": record.Type.KIT_ITEM,
  "Markup": record.Type.MARKUP_ITEM,
  "NonInvtPart": record.Type.NON_INVENTORY_ITEM,
  "OthCharge": record.Type.OTHER_CHARGE_ITEM,
  "Payment": record.Type.PAYMENT_ITEM,
  "Service": record.Type.SERVICE_ITEM,
  "Subtotal": record.Type.SUBTOTAL_ITEM
};

2. search.createColumn

In your search for fetching item records, include the record type as a column.

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

3. const itemRecord

When loading the item record, use the item mapping in square bracket notation to utilize the correct record.Type.

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

Author: John Baylon


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!

Oracle NetSuite Alliance Partner & Commerce Partner

If you have questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart