Search code examples
netsuiterecordsuitescript2.0

record.tranform Transfer Order to Item Receipt throws error


I'm trying to create an item receipt from a transfer order. I am able to transform the record but when I go to save it I get the error

You must enter at least one line item for this transaction.

My code is

var data = JSON.parse(params.data);
//get tranfser order
var lookupResults = search.lookupFields({
    type : search.Type.ITEM_FULFILLMENT,
    id : data.id,
    columns : 'createdfrom'
});
var transferOrderId = lookupResults.createdfrom;
log.debug("Transfer Order", JSON.stringify(lookupResults.createdfrom));
//Create Item Receipt from transfer order
var itemReceipt = record.transform({
    fromType    : record.Type.TRANSFER_ORDER,
    fromId      : transferOrderId[0].value,
    toType      : record.Type.ITEM_RECEIPT
});

log.debug("Data", JSON.stringify(itemReceipt));
itemReceipt.save({
    ignoreMandatoryFields : true
});

The log for Data shows that there are Lines for this item receipt. But for some reason NetSuite throws the error. What am I doing wrong?


Solution

  • You probably have to check itemreceive on each item line you want to receive. Also make sure you are dealing with a shipped fulfillment