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!

 

Rookie Asked on December 20, 2019 in SuiteScript.

What are the values in date and formatDate. If formatDate  is a Date, I prefer to know the value of formatDate.toISOString()

on December 20, 2019.

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

on December 20, 2019.

Looks reasonable. You probably could have used setCurrentSublistText with date and it should work. That said, are you saving the record?

on December 20, 2019.

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?

on December 20, 2019.

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.

on December 20, 2019.

Try a simple hardcoded script

var rec = record.load({
  type: record.Type.PURCHASE_ORDER,
  id: "hardcodeMe",
  isDynamic: true
});
rec.selectLine({
  sublistId: "item",
  line: 0
}); 
log.debug('value before', rec.getCurrentSublistValue({
  sublistId: "item",
  fieldId: "expectedreceiptdate"
})); 
rec.setCurrentSublistValue({
  sublistId: "item",
  fieldId: "expectedreceiptdate",
  value: new Date("2020-01-04T08:00:00.000Z")
}); 
log.debug('value after', rec.getCurrentSublistValue({
  sublistId: "item",
  fieldId: "expectedreceiptdate"
})); 
rec.commitLine({ sublistId: "item" }); rec.save(); 

on December 20, 2019.

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

on June 8, 2020.

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.

on June 8, 2020.

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

on June 8, 2020.

@Chris Abbott, thank you very much! I did stumble my way here and that link solved my issue!!!

on August 9, 2021.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor