I am trying to change the components on a Work Order via script. When I run the following code through the console, it works as expected:
var workOrder = <em>record</em>.load({ type: <em>record</em>.Type.WORK_ORDER, id: 213, isDynamic: true }); while (workOrder.getLineCount({ sublistId: 'item' }) &gt; 0) { workOrder.removeLine({ sublistId: 'item', line: 0 }); } var allComponents = []; allComponents.<strong>push</strong>({ item: 51, quantity: 800 }); allComponents.<strong>push</strong>({ item: 65, quantity: 200 }); for (var j = 0; j &lt; allComponents.length; j++) { workOrder.selectLine({ sublistId: 'item', line: j }); workOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: allComponents[j].item }); workOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: allComponents[j].quantity }); workOrder.commitLine({ sublistId: 'item' }); } workOrder.save();However, when I run the exact same code block (copied and pasted) in a Suitelet, I get "An unexpected SuiteScript error has occurred". It points me to the line where I am setting the item.I have tried loading the record in standard mode and using the "setSublistValue" methods, but no dice. Same error on the same line.Any thoughts?