This topic contains 9 replies, has 0 voices, and was last updated by starlingMark 7 years, 8 months ago.
-
AuthorPosts
-
March 20, 2017 at 9:35 am #1039
starlingMarkI 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:
Code:
var workOrder = record.load({ type: record.Type.WORK_ORDER, id: 213, isDynamic: true });while (workOrder.getLineCount({ sublistId: ‘item’ }) > 0) {
workOrder.removeLine({ sublistId: ‘item’, line: 0 });
}var allComponents = [];
allComponents.push({ item: 51, quantity: 800 });
allComponents.push({ item: 65, quantity: 200 });for (var j = 0; j This is a cached copy. Click here to see the original post.
-
March 20, 2017 at 9:56 am #1040
khultquistI would try using workOrder.setLineItemValue(group, name, linenum, value) instead of workOrder.setCurrentSublistValue()
-
March 20, 2017 at 10:07 am #1041
starlingMarkI believe that is a SS 1.0 call – not a 2.0 call.
-
March 20, 2017 at 10:56 am #1042
khultquistRight, sorry about that. That should say workOrder.setSublistValue(), but in re-reading your post you already tried that. Selecting lineitems/sublists server side has caused my scripts to crash, but that’s not the problem you’re having.
Here’s another thought, is kind of a long shot… try removing the extra sublist lines at the end of your script. It shouldn’t matter until the line is committed, but since this sublist is required to have at least one line it might be causing a server side problem.
Edited to add: in your original script you probably need to use workOrder.selectNewLine() instead of workOrder.selectLine()
Code:
var workOrder = record.load({ type: record.Type.WORK_ORDER, id: 213, isDynamic: true });var allComponents = [];
allComponents.push({ item: 51, quantity: 800 });
allComponents.push({ item: 65, quantity: 200 });for (var j = 0; j 1) {
workOrder.removeLine({ sublistId: ‘item’, line: 2 });
}workOrder.save();
-
March 20, 2017 at 10:57 am #1043
erictgrubaughI have noticed 2.0 being very finnicky about Strings v Numbers with internal IDs. Perhaps try making your `item` properties Strings instead.
Everything else looks correct with your code.
-
March 20, 2017 at 11:20 am #1044
starlingMarkThanks for the suggestions all. I just tried breaking out the “remove extra line items” to right before I save the record. Unexpected error.
Eric – Thanks for your thoughts as well. I tried .toString(), all of the format.format and format.parse variations I could think of. Unexpected error.
For the time being I have written a second suitelet in SS 1.0 that is called from this one. It works perfectly – but is not really the desired methodology.
-
March 20, 2017 at 11:25 am #1045
khultquistDid you try workOrder.selectNewLine() instead of workOrder.selectLine() — I edited my last post, not sure if you saw it. Since line 0 doesn’t exist, you may not be able to select it.
-
March 20, 2017 at 11:32 am #1046
starlingMarkThat, too, returns “Unexpected Error”. But, since this is SS 2.0, line 0 does exist.
-
March 20, 2017 at 1:45 pm #1047
seamanjeffThere’s a defect on this that is supposed to be fixed in 2017.1. It’s Defect 423850. I had SS1 code that worked but in SS2 it gave me problems.
-
March 21, 2017 at 3:48 am #1048
starlingMarkThanks for this Jeff – I thought it was just me!
-
AuthorPosts
You must be logged in to reply to this topic.