Saturday, March 16, 2019

SuiteScript: How to fulfill items from order for one specific purchase order?

The following script demonstrateshow you can create an item fulfillment for items that were back-ordered byspecific purchase order.
This is useful when customer wants to pick up only part of their order that isalready on stock.

var salesOrder = 123; // ID of sales order to be fulfilledvar purchOrder = 124; // your received POvar itf = nlapiTransformRecord('salesorder', salesOrder, 'itemfulfillment');// loop through items on the fulfillment recordfor (var i = 1; i<= itf.getLineItemCount('item'); i++) {    if (itf.getLineItemValue('item', 'createdpo', i) == purchOrder) {        itf.setLineItemValue('item', 'itemreceive', i, 'T'); // fulfill    } else {        itf.setLineItemValue('item', 'itemreceive', i, 'F'); //    }}var itfId = nlapiSubmitRecord(itf);nlapiLogExecutionLog('DEBUG', 'New Item Fulfillment ID', itfId); 

The code can be used as part of auser-event script, standalone Suitelet or RESTlet.

DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Netsuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.

Netsuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Netsuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.

Netsuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.

No comments:

Post a Comment