Scripting, Customization, and Integration

Note:

This content applies to all versions of SuiteScript. However, the links and examples may currently cover only SuiteScript 1.0.

Inbound shipment records let you track in-transit inventory and shipment status. You can assign items from multiple purchase orders to an inbound shipment, then receive and bill them in bulk from the shipment record. You can also use the take ownership record to account for ownership transfers of inbound inventory before receipt.

The internal ID for the inbound shipment record is inboundshipment.

Sample Scripts

The following sample scripts show common inbound shipment workflows.

Example 1: Create, Update, and Receive an Inbound Shipment

  • Creates the inbound shipment record.

  • Adds line items from a purchase order

  • Enters information into the primary information fields

  • Updates the status field

  • Updates the expected shipping date

  • Creates a partial ownership transfer

  • Receives the inbound shipment

            var inboundShipment = nlapiCreateRecord('inboundshipment');
var purchaseOrder = nlapiLoadRecord('purchaseorder', 1718);
var itemLineCount = purchaseOrder.getLineItemCount('item')
for (var i = 1; i <= itemLineCount; i++) {
   inboundShipment.selectNewLineItem('items');
   inboundShipment.setCurrentLineItemValue('items', 'purchaseorder', purchaseOrder.getId());
   inboundShipment.setCurrentLineItemValue('items', 'shipmentitem', purchaseOrder.getLineItemValue('item', 'lineuniquekey', i));
   inboundShipment.commitLineItem('items');
}
var inboundShipmentId = nlapiSubmitRecord(inboundShipment);

var inboundShipmentUpdate = nlapiLoadRecord('inboundshipment', inboundShipmentId);
inboundShipmentUpdate.setFieldValue('shipmentstatus', 'inTransit');
inboundShipmentUpdate.setFieldValue('externaldocumentnumber', 'EDN645');
inboundShipmentUpdate.setFieldValue('expectedshippingdate', '8/2/2017');
inboundShipmentUpdate.selectLineItem('items', 1);
inboundShipmentUpdate.setCurrentLineItemValue('items', 'receivinglocation', 6);
inboundShipmentUpdate.setCurrentLineItemValue('items', 'quantityexpected', 1);
inboundShipmentUpdate.setCurrentLineItemValue('items', 'expectedrate', 10.5);
inboundShipmentUpdate.commitLineItem('items');
nlapiSubmitRecord(inboundShipmentUpdate);

var takeOwnership = nlapiLoadRecord('bulkownershiptransfer', inboundShipmentId);
takeOwnership.selectLineItem('items', 2);
takeOwnership.setCurrentLineItemValue('items', 'process', 'F');
takeOwnership.commitLineItem('items');
nlapiSubmitRecord(takeOwnership);

var bulkReceive = nlapiLoadRecord('receiveinboundshipment', inboundShipmentId);
bulkReceive.selectLineItem('receiveitems', 2);
bulkReceive.setCurrentLineItemValue('receiveitems', 'quantitytobereceived', 1);
bulkReceive.commitLineItem('receiveitems');
nlapiSubmitRecord(bulkReceive); 

          

Example 2: Add Landed Cost to an Inbound Shipment

  • Opens an inbound shipment

  • Adds a new landed cost line

  • Applies the cost to two items

  • Selects the allocation method

  • Adds the landed cost value

  • Sets the landed cost currency

  • Specifies when to apply the exchange rate

            var SEPARATOR = '\u0005'
var inboundShipment = nlapiLoadRecord('inboundshipment', 7);
inboundShipment.selectNewLineItem('landedcost');
inboundShipment.setCurrentLineItemValue('landedcost', 'landedcostshipmentitems', '16' + SEPARATOR + '17'); 
inboundShipment.setCurrentLineItemValue('landedcost', 'landedcostallocationmethod', 'QUANTITY');
inboundShipment.setCurrentLineItemValue('landedcost', 'landedcostcostcategory', '1');
inboundShipment.setCurrentLineItemValue('landedcost', 'landedcostamount', '50');
inboundShipment.setCurrentLineItemValue('landedcost', 'landedcostcurrency', '2');
inboundShipment.setCurrentLineItemValue('landedcost', 'landedcosteffectivedate', '1/30/2018');
inboundShipment.commitLineItem('landedcost');
nlapiSubmitRecord(inboundShipment); 

          

Usage Notes:

  • You can create landed costs through SuiteScript only when the inbound shipment is in edit mode.

  • - 16 and 17 are shipment item line IDs on Items tab. The example nlapiGetLineItemValue('items', 'id', 1);) retrieves the ID for the first line.

    - \u0005 is the separator for multi-select fields.

  • The date format used for '1/30/2018' depends on your account settings.

To learn more, see Inbound Shipment in the SuiteScript help documentation.

Related Topics:

General Notices