Mass Update at Line Level

Back in 2018, I had an interesting challenge at a client that I had implemented NetSuite for three years previous. The old management teams strategy involved running an average costing model across the business, but new management saw the benefit of a standard costing model, and wanted to change the costing method on all of their existing products. Anyone with NetSuite inventory experience knows that changing the costing method is not possible, so when I first heard the requirement, I knew I had an interesting challenge on my hands.

The project was a success and remains one of the most enjoyable and challenging projects I have worked on. Replacing the items was the easier part, it was replacing all items on open transactions that was challenging, especially as they were a manufacturing client who had a large quantity of blanket purchase orders and future dated open work orders. I managed to write a mass update script that replaced all items on the open transactions, however upon replacing the items on open work orders, I found that it didn’t trigger the population of a location field from the header of the inventory item, to the column field on the work order. This location was shown on the picking list and split out into various pages depending on the location, so this could be distributed to different teams that would head off to different locations and pick the required stock.

I wrote a script, and I stress, I am not a developer, however my team at the time had no development expertise and I was on client site alone with a pretty big task on my hands, but I wrote a script that functioned as required and successfully populated the work order column with the appropriate picking location for each component on the work orders.

Below is the code that I wrote:

function updateWOLines(recType, recId) {

 var loadWO = nlapiLoadRecord(recType, recId);
 var itemCount = loadWO.getLineItemCount('item');
 
 for(x = 1; x <= itemCount; x++){
 
  var itemRecord = loadWO.getLineItemValue('item','item', x);
  var itemBinLocation = nlapiLookupField('item', itemRecord, 'custitem_xx_bin_location');
  
  loadWO.setLineItemValue('item', 'custcol_xx_bin_location', x, itemBinLocation);
 }
 
 var submitRec = nlapiSubmitRecord(loadWO);
}

I probably won’t use the script again and if I came across the problem today I would probably outsource it to get it done properly (and in less time), but at a time when you’re on client site and need a lot of work doing quickly, little snippets of code like this can help to make a huge difference. I enjoy improvising and there’s nothing more satisfying than your improvisation working to effect.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s