1
votes

Is it possible to set the price of a sales order item in NetSuite SuiteScript 2.0?

I've got the following function that will set the quanity, amount and description. However, I message is displayed saying that the amount and price does NOT match. It seems that the price field defaults back to the price of the original inventory (or non-inventory in this case) item. Even attempting to set a hard code the value in the function does not work.

  function updateSalesOrderItem(configuredItem) {
console.log("updateSalesOrderItem....")
var salesOrder = currentRecord.get();

var lineItem = salesOrder.selectLine({
  sublistId: "item",
  line: lastItemModified.rowNumber
});
console.log({"lineItem": lineItem});

var priceSubListValue = salesOrder.getCurrentSublistValue({
  sublistId: "item",
  fieldId: "price"
});
console.log({"current price": priceSubListValue});

console.log("  Setting the quantity...");
salesOrder.setCurrentSublistValue({
  sublistId: "item",
  fieldId: "quantity",
  value: configuredItem.quantity
});

// Update the item price to suppress warning message.  Before the item is configured, we don't know the price
// therefore it wouldn't match and the warning message is displayed
/*
var amt = parseFloat(configuredItem.amount);
var q = parseInt(configuredItem.quantity);
var p = amt/q;
var price = p.toFixed(2);

console.log({'price': price});
*/
salesOrder.setCurrentSublistValue({
  sublistId: "item",
  fieldId: "price",
  value: "999.99"
});


salesOrder.setCurrentSublistValue({
  sublistId: "item",
  fieldId: "amount",
  value: configuredItem.amount
});

console.log("  Setting the description...");
salesOrder.setCurrentSublistValue({
  sublistId: "item",
  fieldId: "description",
  value: configuredItem.description
});

salesOrder.commitLine({sublistId: "item"});

}

1

1 Answers

3
votes

set the price level to custom prior to setting the rate.

salesOrder.setCurrentSublistValue({
  sublistId: "item",
  fieldId: "price",
  value: -1
});

salesOrder.setCurrentSublistValue({
  sublistId: "item",
  fieldId: "rate",
  value: 999.00
});

If you are in a jCurve account and can't set a custom price level you may need to set set the item itself as having a variable price. That is available if you have Netsuite ecommerce available in your account.