i am getting this error on a suitscript when I try...
# ask-stanley-ai
m
i am getting this error on a suitscript when I try to receive a fulfillment: MATCHING_SERIAL_NUM_REQD. what is going on?
c
AI generated answer (using internal Slack threads):
The error
MATCHING_SERIAL_NUM_REQD
typically occurs when you are trying to fulfill an order that contains serialized inventory items, but the serial numbers for those items are not provided in the script. Serialized inventory items in NetSuite require a unique serial number for each unit of the item, and this serial number must be specified when the item is received or fulfilled. In the context of SuiteScript, when creating an Item Fulfillment record from a Sales Order that includes serialized items, you need to provide the serial numbers for those items in the
inventorydetail
sublist of the Item Fulfillment record. This sublist is used to capture the inventory detail (like serial numbers or lot numbers) for line items on the fulfillment. Here is a sample code snippet that demonstrates how to set the serial numbers on an Item Fulfillment record:
Copy code
javascript
var fulfillmentRecord = record.transform({
    fromType: record.Type.SALES_ORDER,
    fromId: salesOrderId,
    toType: record.Type.ITEM_FULFILLMENT,
    isDynamic: true,
});

var numLines = fulfillmentRecord.getLineCount({ sublistId: 'item' });

for (var i = 0; i < numLines; i++) {
    fulfillmentRecord.selectLine({ sublistId: 'item', line: i });

    var inventoryDetailSubrecord = fulfillmentRecord.getCurrentSublistSubrecord({
        sublistId: 'item',
        fieldId: 'inventorydetail'
    });

    inventoryDetailSubrecord.selectNewLine({ sublistId: 'inventoryassignment' });
    inventoryDetailSubrecord.setCurrentSublistValue({
        sublistId: 'inventoryassignment',
        fieldId: 'issueinventorynumber',
        value: 'SERIAL_NUMBER_HERE' // replace with actual serial number
    });
    inventoryDetailSubrecord.commitLine({ sublistId: 'inventoryassignment' });

    fulfillmentRecord.commitLine({ sublistId: 'item' });
}

fulfillmentRecord.save();
Please replace
'SERIAL_NUMBER_HERE'
with the actual serial number for the item. If you have multiple serialized items on the order, you will need to provide the serial numbers for each of them. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823303282
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822235167
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822204709
Please provide your feedback on this answer.