Programming Item Groups is not well documented. If you plan to do anything with them via SuiteScript, I’d encourage you to review these notes first.
What brings me to this post? I’m currently augmenting NetSuite’s estimate module. In order to accomplish this, I needed a full working knowledge of Item Groups. Here are my notes, mostly for me, but feel free to use them too.
- When you add an item group as a single part, NetSuite expands that to include all parts/items included defined in the group.
- Once added to a transaction, the items in the group are fully editable (unlike Kits).
- Items are added in the quantities defined in the group and at the current price assigned to a customer. This will include the customer’s “Pricing Group” price. If that is not present, then an alternate price level for that customer. And if that is not present, then the item’s base price. So, standard pricing rules apply!
- Under the hood of a transaction, Item Groups will include the following lines:
- An item Group definition, complete with item name and description. No price.
- A line item for each item included in the group’s definition.
- An “EndGroup” item, with an internalId of zero.
- To delete an item group, you delete the “Group” item. All sub-items will be removed with it.
- To add a group item via SuiteScript, it works differently between server-side and client-side. This is very (very, very) important! At the time of this writing, you won’t find this documented anywhere else.
Here are some examples in SuiteScript 2.0. I’m testing in version 2019.2.
When deleting an item group, simply delete the item with type=”Group”. That takes all items between it and including the item with type=”EndGroup”.
If you are executing a server-side script, in a Suitelet or Restlet, adding an Item Group is as simple as adding an item. Just add the group item and the rest will magically follow.
The really tricky scenario is when you’re writing a client-side script. In this case you need to know some rules.
- You must add the “Item Group” item first.
- Then you must add items that will be included in the group. Since Item groups are editable via a client-side script, you can literally add whatever sub-items you want here! However, it might be nice to actually lookup the items in the group and add those.
- If you specify a quantity on any sub-items that differ from the quantities defined in the group, it overrides Item Group defined quantities. This automatically changes the total price of the group. When I say overrides, I mean in the transaction you’re currently working on. The actual definition of the Item Group remains unchanged.
- If you specify a rate (unit price) or amount (extended price) that differs from the values defined in the group, it override those values and changes the total on the group (again, in the current transaction).
- Quantities, rates and amounts are optional on sub-items. Leave them off, you get system-defined values.
- You must add a trailing item of type “EndGroup” with an internalId of zero. It must also have a tax code defined (or at least in my system it did).
Here is an example showing how to add an item group in client-side SuiteScript. In my example, my group actually contains 3 sub-items. I’m only adding one. I’m also changing the quantity, rate (unit price) and amount (extended price) on the sub-item. I was verifying that it correctly updated the group’s total price and cost. It did!
I plan to return to this post whenever I’m working on Item Groups. There are simply too many rules to remember. I’ll need these notes!
Here is the code in format you can cut and paste into your debugger.
One thought on “SuiteScript – Item Groups”
Thank you! This was really helpful.
I was updating an old SuiteScript 1.0 script but the same concepts apply there also, namely, adding an “EndGroup” item with itemid 0 and a valid taxcode.