4

I'm trying to set a SalesOrder to fulfilled using the PHP Netsuite Api but I keep getting the following error:

VALID_LINE_ITEM_REQD - You must have at least one valid line item for this transaction.

I'm using the https://github.com/ryanwinchester/netsuite-php library.

I have the following so far. I've tried using the Initialise methods as well that I've seen in some examples, but they all seem to give the same error. We're using Advanced Inventory Management if that helps.

$itemFulfillment = new ItemFulfillment();

// Sales Order
$itemFulfillment->createdFrom = new RecordRef();
$itemFulfillment->createdFrom->internalId = <SALES_ORDER_ID>;

$itemFulfillment->shipStatus = ItemFulfillmentShipStatus::_shipped;

// Customer
$itemFulfillment->entity = new RecordRef();
$itemFulfillment->entity->internalId = <CUSTOMER_ID>;

// List
$fullfillmentList = new ItemFulfillmentItemList();
$fullfillmentList->replaceAll = true;

foreach($salesOrder->itemList->item as $saleItem) {
    $item = new ItemFulfillmentItem();
    $item->location = new RecordRef();
    $item->location->internalId = 4;
    $item->item = new RecordRef();
    $item->item->internalId = $saleItem->item->internalId;
    $item->itemIsFulfilled = true;
    $item->itemReceive = true;
    $item->quantity = $saleItem->quantity;
    $item->orderLine = $saleItem->line;           

    // Department Reference
    $departmentRec = new RecordRef();
    $departmentRec->internalId = 5;
    $item->department = $departmentRec;

    $fullfillmentList->item[] = $item;
}

$itemFulfillment->itemList = $fullfillmentList;


$request = new AddRequest();
$request->record = $itemFulfillment;

$client->add($request);

Any help would be great. :)

Phill
  • 51
  • 1
  • 4

2 Answers2

1

Transforming a Sales Order to a

Cross-Subsidiary Item Fulfillment Record will return a "VALID_LINE_ITEM_REQD >

You must have at least one valid line item for this transaction" error if we did not specify an inventoryLocation in the defaultValue parameter.

function createIF(soId, invLocation) { var itemFulfillment = record.transform({ fromType: record.Type.SALES_ORDER, fromId: soId, toType: record.Type.ITEM_FULFILLMENT, defaultValues: { inventorylocation: invLocation } }); /** * You can insert other script logic here */ var ifID = itemFulfillment.save(); return ifID; }

Harish
  • 189
  • 2
  • 13
0
  • make sure the item is in inventory
  • make sure the item is available to your subsidiary
  • make sure you are committing sublists correctly, if applicable
  • dump $saleItem to see whats in it to make sure noting is null
xpeldev
  • 1,812
  • 2
  • 12
  • 23