Charl
Charl

Reputation: 827

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!

Upvotes: 2

Views: 2878

Answers (2)

PabloInNZ
PabloInNZ

Reputation: 555

This is the first thing that pops up when I google for the same error, so hopefully this may help someone and save a few hours of their life ! I know it's not strictly an answer to the question asked. In my case I had this same error when trying to create an Item Receipt for a Purchase Order. The issue turned out to be that I was not incrementing the lineOrder parameter for the ItemReceiptItem. Therefore I had multiple lines in the Item Receipt that had the same lineOrder (which matches to that in the original Purchase Order). Would have been more useful if the error message said something along the lines that there were duplicates.

Upvotes: 0

Charl
Charl

Reputation: 827

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();

Upvotes: 1

Related Questions