Scripting, Customization, and Integration

Note:

The content below pertains to all versions of SuiteScript. Be aware that currently it may only include links or examples for SuiteScript 1.0.

Inbound shipments provide visibility of in-transit inventory and the status of a shipment. Items from multiple purchase orders can be assigned to an incoming shipment and bulk received and billed from within the record. Accounting support is also provided for the transfer of ownership of inbound inventory prior to receipt. This is done from the take ownership record.

The internal ID for the inbound shipment record is inboundshipment.

Sample Scripts

The following script examples illustrate typical workflows for an inbound shipment.

Example 1

  • 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

  • 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

1. Landed Costs can only be created in SuiteScript when the inbound shipment is in edit mode

2.

- 16 and 17 = shipment item line ids on Items tab (nlapiGetLineItemValue('items', 'id', 1);)

- \u0005 = separator for multi-select fields

3. Date format for '1/30/2018' is dependent on your account settings

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

Related Topics:

General Notices