```//transform SO to create a new Item fulfillment...
# suitescript
k
Copy code
//transform SO to create a new Item fulfillment
var fulfillment = record.transform({
  fromType: record.Type.SALES_ORDER,
  fromId: currentRecord.id,
  toType: record.Type.ITEM_FULFILLMENT,
  isDynamic: true
});

//get line count of newly created fulfillment
var lineCount = fulfillment.getLineCount({
    sublistId: 'item'
});

//for each line set the "itemreceive" field to true
for (var i = 0; i < lineCount; i++) {
  fulfillment.selectLine({
      sublistId: 'item',
      line: i
  });
  fulfillment.setCurrentSublistValue({
      sublistId: 'item',
      fieldId: 'itemreceive',
      value: true
  });

  //set other relevant sublist fields
  fulfillment.setCurrentSublistValue({
      sublistId: 'item',
      fieldId: 'fieldId',
      value: 'value'
  });
  fulfillment.commitLine({
      sublistId: 'item'
  });
}

//set any other relevant itemreceive fields
itemreceive.setValue({
  filedId: 'fieldId',
  value: 'value'
});

//save the newly created itemreceive
var itemreceiveId = itemreceive.save({
  enableSourcing: true, //optional, defaul is false
  ignoreMandatoryFields: true  //optional, defaul is false
});
Hi all, Is there a way for me to use Lineid instead of Line (index) to do transform from sales order to Item fulfillment? Because I'm getting error Null stack
n
Your not actually doing this are you?
Copy code
fulfillment.setCurrentSublistValue({
      sublistId: 'item',
      fieldId: 'fieldId',
      value: 'value'
  });
I presume you're supplying relevant fieldId's and value's... As for your Lineid / Line question where are you using either and in what way are you thinking you're using either?
k
I'm trying to make item fulfillment and use line ID as a key value to populate my inventory detail
Wanted to know if it was possible because I have alternative solution which is to create a saved search to get non fulfilled item which has the same top down layout.