Tip – 42: Create Item Fulfillment record from Fulfillment Request record using Suite Script 2.0 in NetSuite/ Fulfill Sales Order, if Sales Order has Fulfillment Request attached to it.

Recently working on a task to create Item fulfillment record from Fulfillment record using SuiteScript.

Existing Process: If you have enabled Fulfillment Request, On Sales Order, you won’t see Fulfill button instead, you will see Fulfillment Request Button.

On Click of Fulfillment Request record, you can create Item Fulfillment record from Fulfillment Request record, not from Sales Order.

But when I was trying replicate the same process using SuiteScript, I found that record.transform() doesn’t support From Type as “fulfillmentrequest”. So below code won’t work.

var objRecord = record.transform({
fromType:’fulfillmentrequest’,
fromId: requestId,
toType: ‘itemfulfillment’,
isDynamic: true
});

Then I tried creating Item fulfillment directly from Sales Order as below.

var objRecord = record.transform({
fromType:’salesorder’,
fromId: soId,
toType: ‘itemfulfillment’,
isDynamic: true,
});

But that didn’t work too, as once Fulfillment request is attached to a Sales Order, above code will not work to create Item Fulfillment from Sales Order.

Then I searched for a filed, where I can set the fulfillment request ID, while transforming Sales Order to Item Fulfillment record. But I didn’t find any such field.

Then further investigation, I found that upon clicking Fulfill button from Fulfillment Request, on new Item Fulfillment page the URL contains below parameters:

transform=salesor&fftreqid=xxxxxx&whence=&shipgroup=1

So I observed that even if Item Fulfillment comes from Fulfillment Request, but in backend its getting transformed from Sales Order with parameter ffrerid with Fulfillment Request ID and shipgroup = 1.

Then I tried to replicate the same in the script as below:

var objRecord = record.transform({
fromType:’salesorder’,
fromId: soId,
toType: ‘itemfulfillment’,
isDynamic: true,
defaultValues: {
fftreqid: requestId,
shipgroup: 1 }
});

And it worked.

Hope when you have similar requirement, this tip will definitely work.

Happy Coding 🙂

Asha