setCurrentSublistValue (or maybe commitLine) not working, but no errors
Hello everyone,
In a Suitelet, upon a custom form submission, I am trying to update a date field on an item in the item sublist of a purchase order. My form is Ok, in that I can see the submitted values of the inputs in context.request.parameters. So my code looks something like this:
var params = context.request.parameters, line = params.line, date = params.date, poId = params.po, options = {type:'purchaseorder', id:poId, isDynamic:true}, rec = record.load(options), formatDate = format.parse({value:date, type:format.Type.DATE}); rec.selectLine({ sublistId: "item", line: line }); rec.setCurrentSublistValue({ sublistId: "item", fieldId: "expectedreceiptdate", value: formatDate }); rec.commitLine({sublistId:"item"});
What’s happing is . . . nothing! The field `expectedreceiptdate` doesn’t update, and there are no errors. Any help is appreciated!
battk
What are the values in date and formatDate. If formatDate is a Date, I prefer to know the value of formatDate.toISOString()
mreser
battk, date is like this ’01/04/2020′
I format it and formateDate is “2020-01-04T08:00:00.000Z”
Running it through the format was the only way I could get NS not to error out on setCurrentSublistValue
But I don’t think my problem is the date. I can change ‘expectedreceiptdate’ to ‘quantity’ and hard code a simple value in, and it does the exact same thing: no error, but does not change/update/set the sublist value.
Additionally, if it is helpful, I can put a log before and after the commitLine({…}) call and both of those logs will show in the execution log
battk
Looks reasonable. You probably could have used setCurrentSublistText with date and it should work. That said, are you saving the record?
mreser
When I add rec.save() after the
rec.commitLine({sublistId:
"item"
});
line, I get this error: “INSUFFICIENT_PERMISSION”,”message”:”Permission Violation: You need a higher level of the ‘Transactions -> Purchase Order’ permission to access this page.But here’s the thing . . . I already have that permission set on the role that is executing this script (set the role in the deployment, set Transactions -> Purchase Order’ on the role). So I am not sure why I am getting that permission error when it is clearly set, and indeed, I got that error the in the GET part of this suitelet when I was building the form. So, is the POST / form submission breaking that permission?
mreser
So I didn’t have the permission of ‘Transactions -> Purchase Order’ quite high enough . . . I set it to Full.
But still, same thing: nothing happens. No errors (so setting it to high removed the permission error), but save didn’t fix it either.
battk
Try a simple hardcoded script
Chris Abbott
mreser,
Did you find the root cause here? I’m trying to set taxcode via a Client Script and am finding that commitLine isn’t working.
Thanks,
Chris
mreser
abbott, I don’t recall exactly what fixed this, but I believe it was the date formatting. Sometimes when the date is not formatted correctly, I receive an error, other times just nothing seems to happen like what happened in this scenario. This seems dependent on the type of SuiteScript and maybe other factors; I honestly am not sure.
Chris Abbott
Thanks, mreser.
In case anyone else finds there way here, I think I just solved my issue with:
https://netsuite.custhelp.com/app/answers/detail/a_id/67333/kw/commitline
btgoligowski24
@Chris Abbott, thank you very much! I did stumble my way here and that link solved my issue!!!