Add an Item Group to Sales Order in Netsuite using SuiteTalk and PHP

1.5k Views Asked by At

I am trying to add Sales Orders with items of type "Item Group" using SuiteTalk via the PHP Toolkit.

When the item is of other types, e.g. "Inventory Item, Non-Inventory Item", the orders is added without problems.

When the item is of type "Item Group", I get the following error:

Code: INVALID_KEY_OR_REF Message: Invalid price reference key 1 for item NNNNNN. Type: ERROR

Where NNNNN is the internal ID of the child Inventory Item connected to this Item Group

Here is how I set my SalesOrderItem:

$nsItem = new SalesOrderItem();

$nsItem->item = new RecordRef();
$nsItem->item->internalId = $orderItem->product->foreignId;
$nsItem->item->type = $orderItem->product->itemType;
$nsItem->item->typeSpecified = true;

$nsItem->price = new RecordRef();
$nsItem->price->type = "priceLevel";
$nsItem->price->internalId = "-1"; // the default custom price level
$nsItem->rate = $orderItem->amounts->price;

$nsItem->quantity = $orderItem->qty;

Any thoughts?

UPDATE:

I made a workaround - I am checking each Sales Order Item for its type and if it is "Item Group" I am populating the Sales Order with the items from this group. It is a little bit slower but works.

1

There are 1 best solutions below

1
On

If you run into this error, you'll notice that the item ID which is causing the error is not the same item specified on the header level of the invoice/sales order. The issue here is the "Base Price" (or whatever price level is internal ID 1) is not defined on that component item of the item group.

If you specify the "Base Price" this error will disappear!