Fulfillment Request

The fulfillment request record represents a request or demand to fulfill a sales order at a fulfillment location. You create a fulfillment request record from a sales order record.

To use this record, you must have the Fulfillment Request feature enabled.

For help working with this record in the UI, see Fulfillment Requests.

The internal ID for this record is fulfillmentrequest.

For information about scripting with this record in SuiteScript, see the following help topics:

See the SuiteScript Records Browser for all internal IDs associated with this record.

Supported Script Types

The fulfillment request record is scriptable in both client and server SuiteScript.

Supported Functions

This record supports the following functions: read, edit, transform, delete, and search.

Note:

The create and copy functions are not supported.

Usage Notes

To create a fulfillment request record, you must have a sales order ID. The Fulfillment Choice and Location must also be set on each line in the sales order. Depending on the selected fulfillment choice (Ship or Store Pickup), NetSuite sets the fulfillment request type to Ship or Store Pickup respectively. If there are multiple lines on the sales order with different fulfillment choices or locations, you must create separate fulfillment requests for each location/fulfillment choice combination. If all lines on the sales order have the same fulfillment choice and location, you create a single fulfillment request. Trying to create a fulfillment request with different fulfillment choices or different locations results in an exception.

For example, if a sales order has two lines, with the fulfillment choice on the first line set to Ship, and the fulfillment choice on the second line set to Store Pickup, you need to create two fulfillment request records.

Note:

When you automate the creation of fulfillment requests in your account, NetSuite creates the required number of fulfillment requests automatically.

Fulfillment requests have one of several statuses. Only some statuses can be set with SuiteScript. Other statuses are set by NetSuite and are based on the fulfillment state of the line items in the fulfillment request. The following table lists the possible statuses of the fulfillment request record. See Fulfillment Request Statuses for more information about fulfillment request statuses.

Status Code

Status Name

Settable

A

New

Yes

B

In Progress

Yes

C

Cancelled

Yes

D

Picked

No

I

Packed

No

E

Partially Fulfilled

No

G

Fulfilled with Exceptions

No

F

Fulfilled

No

R

Rejected

No

You can add fulfillment request exceptions at the line item level to a fulfillment request. To create a fulfillment request exception, you need to supply a quantity, an exception type, and an exception reason. The exception reasons are different for each exception type. The following table lists the exception types and reasons.

Exception Type ID

Exception Type

Exception Reason ID

Exception Reason

1

Picking

-1

Inventory mismatch

-2

Physical damage

-3

Other

2

Packing

-4

Packing material shortage

-5

Other

3

Picking up

-6

Too heavy

-7

Too big

-8

Wrong color

-9

Other

4

Shipping

-10

Shipper can’t pick up

-11

Shipper did not arrive for pick up

-12

Shipping address issues

-13

Other

Code Samples

Example 1: Create a fulfillment request from a sales order. This sample shows how to create a fulfillment request from a sales order. The sales order ID is 321654. Use record.transform(options) to transform the sales order record to a fulfillment request.

          var fulfillmentRequestRecord = record.transform({

    fromType: record.Type.SALES_ORDER,

    fromId: 321654,

    toType: record.Type.FULFILLMENT_REQUEST,

    isDynamic: true

});

var fulfillmentRequestRecordId = fulfillmentRequestRecord.save(); 

        

Example 2: Add a fulfillment exception on a fulfillment request. This sample shows how to add one fulfillment exception reason to an existing fulfillment request. The fulfillment request ID is 221100. The fulfillment exception is for the second line item in the fulfillment request.

          var fulfillmentRequestRecord = record.load({

    type: 'fulfillmentrequest',

    id: 221100,

    isDynamic: true

});

fulfillmentRequestRecord.selectNewLine({

    sublistId: 'fulfillmentexception'

});

fulfillmentRequestRecord.setCurrentSublistValue({

    sublistId: 'fulfillmentexception',

    fieldId: 'itemline',

    value: 2

});

fulfillmentRequestRecord.setCurrentSublistValue({

    sublistId: 'fulfillmentexception',

    fieldId: 'exceptionquantity',

    value: 1

});

fulfillmentRequestRecord.setCurrentSublistValue({

    sublistId: 'fulfillmentexception',

    fieldId: 'exceptiontype',

    value: 1

});

fulfillmentRequestRecord.setCurrentSublistValue({

    sublistId: 'fulfillmentexception',

    fieldId: 'exceptionreason',

    value: -1

});

fulfillmentRequestRecord.setCurrentSublistValue({

    sublistId: 'fulfillmentexception',

    fieldId: 'exceptioncomments',

    value: fulfillmentRequestExceptionLine.getExceptionComments()

});

fulfillmentRequestRecord.commitLine({

    sublistId: 'fulfillmentexception'

});

 

var fulfillmentRequestRecordId = record.save(); 

        

Example 3: Create fulfillment requests on a sales order with different fulfillment choices. If a sales order has different fulfillment choices or locations at the line level, you first need to get the values of the fulfillment choice and location fields on each line. As you loop through lines in the fulfillment request, you check whether the values on the line are the same as the values on the first line; if they are different, you discard the line.

          var salesOrderID = 321654;

 

var fulfillmentRequestRecord = record.transform({

    fromType: record.Type.SALES_ORDER,

    fromId: salesOrderID,

    toType:  record.Type.FULLFILLMENT_REQUEST,

    isDynamic: true

});

var fulfillmentRequestLinesCount = fulfillmentRequestRecord.getLineCount({

    sublistId: 'item'

});



while (fulfillmentRequestLinesCount > 0)

{

    var initialLocation = null;

    var initialItemFulfillmentChoice = null;

 

    for (line = 1; line <= fulfillmentRequestLinesCount; line++) {

        var currentLocation = fulfillmentRequestRecord.getSublistValue({

            sublistId: 'item',

            fieldId: 'location',

            line: line

        });

        var currentItemFulfillmentChoice = fulfillmentRequestRecord.getSublistValue({

            sublistId: 'item',

            fieldId: 'itemfulfillmentchoice',

            line: line

        });



        if (initialLocation === null) {

            initialLocation = currentLocation;

            initialItemFulfillmentChoice = currentItemFulfillmentChoice;

        }

 

        if ((initialLocation === currentLocation) && (initialItemFulfillmentChoice === currentItemFulfillmentChoice)) {

            fulfillmentRequestRecord.setSublistValue({

                sublistId: 'item',

                fieldId: 'itemreceive',

                line: line,

                value: true

            });

        }

        else {

            // Discard the line because its location or fulfillment choice is different

            fulfillmentRequestRecord.setSublistValue({

                sublistId: 'item',

                fieldId: 'itemreceive',

                line: line,

                value: false

            });

        }

    }

 

    fulfillmentRequestRecordId = fulfillmentRequestRecord.save();

       

    var fulfillmentRequestRecord = record.transform({

        fromType: record.Type.SALES_ORDER,

        fromId: salesOrderID,

        toType:  record.Type.FULLFILLMENT_REQUEST,

        isDynamic: true

    });

    var fulfillmentRequestLinesCount = fulfillmentRequestRecord.getLineCount({

        sublistId: 'item'

    });

} 

        

Related Topics

General Notices