Trying to loop thru a sales order and change the l...
# suitescript
m
Trying to loop thru a sales order and change the location of each line item. Setup a custom list field referencing locations to allow user to pick where it should be reassigned. Reassigns the ORDER Location just fine, but not updating item locations. Thoughts?
Copy code
function updateLocation() {
  var location_new = nlapiGetFieldValue('custbody_so_change_location_to');
  var location_old = nlapiGetFieldValue('location');
  var count     = nlapiGetLineItemCount('item');
  var ret    = "";

  //UPDATE LINE ITEM LOCATION
  for (i = 1; i <= count; i++) {
    nlapiSelectLineItem('item', i);
    nlapiSetCurrentLineItemValue('item', 'location', location_new, true, true);
  }

  ret = ret + "Updated " + count + " line item(s) to location " + location_new + "\n";

  nlapiSetFieldValue('location',location_new);

  return ret;

}