netsuitesuitescript2.0clientscript

SuiteScript Select Line which does not exist returns an error


When I try to add new line and selectLine() it returns an error that SSS_INVALID_SUBLIST_OPERATION This is because that line is not exist. If I use selectNewLine() it works. But I can't use this because I have already existing lines. Is there any method that I can check if that line is new line or not by linekey please?

In Client script when the field is changed I try to get that value and change the next value. I can't use setSublistValue because it returns me an error that function does not exist So I try to get current record first and select the line and set field value

var record = currentRecord.get();    
record.selectLine({sublistId:"custpage_sublist1", line:lineKey});
record.setCurrentSublistValue({sublistId:'custpage_sublist1', fieldId:'custcol_2',  value:"TEST", ignoreFieldChange:true});

This returns an error when I try to add a new line.


Solution

  • During line entry the fieldChanged and postSourcing functions already have the line selected. You can just use

    record.getCurrentSublistValue(...);

    You don't have to select the line because you are already there.