Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Stay in the Know
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Updating a Work Order via script
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(); 0