Search code examples
netsuitesuitetalkfulfillment

Unable to find a matching line for sublist item with key: [orderLine] and value: [1]


I am using SuiteTalk to create an item fulfillment from an existing sales order. This works for non-serialized orders, but not for serialized SOs.

I get the following error:

Unable to find a matching line for sublist item with key: [orderLine] and value: [1].

The line numbers do however match, since there is only one line, and this has line number "1". The line item does have a quantity of 3, each item being added to the fulfillment separately with the same line number. Could this be the problem?

My code:

ItemFulfillmentItem ffItem = new ItemFulfillmentItem();
ffItem.item = ifitemlist.item[b].item;
ffItem.itemReceive = true;
ffItem.itemReceiveSpecified = true;
ffItem.itemIsFulfilled = true;
ffItem.itemIsFulfilledSpecified = true;
ffItem.orderLineSpecified = true;
ffItem.orderLine = ifitemlist.item[b].orderLine;
ffItem.quantity = msg.despatchCartons[i].items[a].qtyDespatched;
ffItem.quantitySpecified = true;
ifitems.Add(ffItem);

For the specific fulfillment, the above code runs 3 times. This is because each of the 3 items on this Line has a separate serial number.

Any help would be appreciated. Thanks in advance!


Solution

  • To resolve this, you need to create an Inventory Detail record for each line on the Item Fulfillment record. The Inventory Detail record will contain the serial number and quantity per serial number for the specific line item.

    The SuiteScript 2.0 code for this, using a User Event script:

    var currentRecord = scriptContext.currentRecord;
    var subrecordInvDetail = currentRecord.getSublistSubrecord({
           sublistId: 'item',
           fieldId: 'inventorydetail',
           line: item_line_num
    });
    

    Run the following code for each serial number on your current line:

    subrecordInvDetail.setSublistValue({
         sublistId: 'inventoryassignment',
         fieldId: 'issueinventorynumber',
         line: serial_num_line,
         value: 'Serial_Number'
    });
    subrecordInvDetail.setSublistValue({
         sublistId: 'inventoryassignment',
         fieldId: 'quantity',
         line: serial_num_line,
         value: 'Quantity_Value'
    });
    subrecordInvDetail.save();