hey folks, if I have something like this in a Suit...
# suitescript
m
hey folks, if I have something like this in a Suitelet when the method is a POST (I am trying to save a form and update a field value on an item in the item sublist of a PO):
var params = context.request.parameters,
line = params.line,
// line, above, logs as a number, like 5
po = params.po,
options = {type:'purchaseorder', id:po, isDynamic: true},
rec = record.load(options);
var selected = rec.selectLine({
sublistId: "item",
line: line
});
I am getting this error:
Error: SSS_INVALID_SUBLIST_OPERATION
{"type":"error.SuiteScriptError","name":"SSS_INVALID_SUBLIST_OPERATION","message":"You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist."
So the line exists... are item sublists not ediatable?
b
selecting lines is for dynamic mode
m
so when I load the record with isDynamic: true, that isn't dynamic mode?
b
so that looks correct, you might want to try hardcoding line to 0
m
so the issue with that is that it isn't line 0 that I want to update. I need to set the lines dynamically (that's why I am setting its value based on the parameters)... or maybe I am misunderstanding what line means in this case, but I can get the lines I need to return. if I hard code in the line I need to edit, like 5, I get the same error
b
how many lines on the purchase order
m
there are 8. I need to change 3 of the 8 . . . one of the 8 is line 5. I was trying to get this to work with just one of the 3 first... I am setting all this in the Suitlet when the method is GET
oh, sorry on this particular PO there are 5. I need to change 3 of the five.. another one I am wortking with has 8
b
0 index based
0,1,2,3,4 are your valid options
m
so line isn't l
So that line isn't the line then apparently
b
the line refers to line id
m
ok, well, that makes sense... I had line meanings mixed up
b
the line used in the suitescript api refers to the line sequence number
1st line is line 0, 2nd is line 1 and so on
m
ok, that's a bummer for what I am trying to do, because I won't know the sequence in this case
b
load the record and find the matching line
m
thanks for your help... is there a better way to edit PO item sublist field values when saved via form in a Suitelet?
ok, I am loading the record
b
you can check each row, or use Record.findSublistLineWithValue(options)
m
ok, thanks. I'll have to try some things. I am attempting to set a received by date field on certain items in the sublist, so the form has multiple date inputs