A lot of tutorials or reference on how to deal with netsuite sublist but none of them fits what I needed.
I just need to update/add the custom sublist I created in suitelet through client script. This is my suitelet code
//this is a custom sublist
var sublist = form.addSubList('targetlist', 'list', null, 'target_list');
sublist.addField('industry', 'text', 'Industry');
sublist.addField('inp_name', 'text', 'Name');
And in client script I just want to add some line items when some field change like
function targetListClient(type, name, lineNum) {
if(name == 'industry') {
nlapiSelectNewLineItem('targetlist');
nlapiSetCurrentLineItemValue('targetlist', 'industry', 'test');
nlapiSetCurrentLineItemValue('targetlist', 'inp_name', 'test again');
nlapiSetCurrentLineItemValue('targetlist', 'jobtitle', 'another test');
nlapiCommitLineItem('targetlist');
}
}
I think this should work but I got this error. Uncaught TypeError: Cannot read property 'checkvalid' of undefined
I also try to just set the line item nlapiSetLineItemValue('industry', 1, 'again')
instead of selecting the current line item but this also is not working.
Am I implementing the sublist concept incorrect? Can someone guide me on this. Thanks.
In function targetListClient, you give a value for field jobtitle, but the sublist creation code only has fields industry and inp_name.