Skip to content

SuiteScript: Inventory Transfer via Code

by admin on January 13th, 2010

Pre 2009.2, transferring inventory quantity from one location to another via SuiteScript can only be done through inventoryadjustment. First you have to add quantity to destination location.

xfer.setLineItemValue("inventory", "item", 1, ITEM_ID);
xfer.setLineItemValue("inventory", "location", 1, LOC_DESTINATION);
xfer.setLineItemValue("inventory", "adjustqtyby", 1, "5");

Then you have to deduct the quantity from the origin location

xfer.setLineItemValue("inventory", "item", 2, ITEM_ID);
xfer.setLineItemValue("inventory", "location", 2, LOC_ORIGIN);
xfer.setLineItemValue("inventory", "adjustqtyby", 2, "-5");

Putting it all together, the code will roughly look like this:

var xfer = nlapiCreateRecord("inventoryadjustment");
xfer.setFieldValue("account", SAMPLE_ACCOUNT);

// add qty to destination
xfer.setLineItemValue("inventory", "item", 1, ITEM_ID);
xfer.setLineItemValue("inventory", "location", 1, LOC_DESTINATION);
xfer.setLineItemValue("inventory", "adjustqtyby", 1, "5");

// deduct qty from origin
xfer.setLineItemValue("inventory", "item", 2, ITEM_ID);
xfer.setLineItemValue("inventory", "location", 2, LOC_ORIGIN);
xfer.setLineItemValue("inventory", "adjustqtyby", 2, "-5");

var id = nlapiSubmitRecord(xfer, true);

With the 2009.2 update, users can directly create an inventorytransfer record. They just need to specify the origin (location) and the destination (tolocation) and NetSuite implicitly add the quantity specified to the destination and deduct the quantity from the origin.

var xfer = nlapiCreateRecord("inventorytransfer");

xfer.setFieldValue("subsidiary", SUBSIDIARY_ID);
xfer.setFieldValue("account", SAMPLE_ACCOUNT);
xfer.setFieldValue("memo", "Sample Inventory Transfer");

xfer.setFieldValue("location", LOC_ORIGIN);
xfer.setFieldValue("tolocation", LOC_DESTINATION);
xfer.setLineItemValue("invt","invtid",1, ITEM_ID);
xfer.setLineItemValue("invt","adjustqtyby", 1, "5");

var id = nlapiSubmitRecord(xfer);

Pretty neat!

From → netsuite

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS