Add new comment

By creating an ItemFulfillment record without specifying item list with quantity fulfilled, Netsuite automatically assume that the order is fulfilled entirely. This is the reason the 2nd item fulfillment record cannot be created, and the INVALID_INITIALIZE_REF error. To circumvent this issue, we need to specify quantity of each line item fulfilled so that the order is partially fulfilled if not all line items are fulfilled.

Partial fulfillment is achieved by creating an Item Fulfillment record with InitializeRecord operation, and assign quantity of the items that will not be fulfilled to zero. Here is the desired request.xml file:

To accomplish this with PHP, we can initialize Item Fulfillment record from Sales Order like an example below:

$initializeObject = new nsComplexObject("InitializeRecord");
$initializeResponse = $myNSclient->initialize($initializeObject);
items = array();
if (!empty($initializeResponse->record)) {
	$orgItemList = @$initializeResponse->record->getField('itemList');
	$orgItems = @$orgItemList->getField('item');
	if (!is_array($orgItems)) {
		$orgItems = array($orgItems); // If single element, make an array
	// Let's assume that we are only fulfilling 1st item.
	// and not fulfill 2nd item.
		$itemFields = array (
			'item' => $orgItems[0]->getField('item'),
			'orderLine' => $orgItems[0]->getField('orderLine'),
			'quantity' => 1
		$item = new nsComplexObject('ItemFulfillmentItem');
		$items[] = $item;
		$itemFields = array (
			'item' => $orgItems[1]->getField('item'),
			'orderLine' => $orgItems[1]->getField('orderLine'),
			'quantity' => '0.0'
		$item = new nsComplexObject('ItemFulfillmentItem');
		$items[] = $item;

// Packaging Information
$packageFields = array (
		'packageWeight' => $data['packageWeight'],
		'packageDescr' => $data['packageDescr'],
		'packageTrackingNumber' => $data['packageTrackingNumber']
$package = new nsComplexObject('ItemFulfillmentPackage');

$packageListFields = array ('package' => $package );
$packageList = new nsComplexObject('ItemFulfillmentPackageList');

$itemFulfillment = new nsComplexObject('ItemFulfillment');
$fulfillmentFields = array (
		'createdFrom'     =>    new nsRecordRef (
				array('internalId'=>$id, 'type' =>'salesOrder' )),
		'packageList'     =>    $packageList,
if (!empty($items)) {
	$itemListFields = array ('item' => $items );
	$itemList = new nsComplexObject('ItemFulfillmentItemList');
	$fulfillmentFields['itemList'] = $itemList;

$response = $myNSclient->add($itemFulfillment);
By admin

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.