Not able to Set Line Item's Value properly in Netsuite Script?

Hi All,

I remember that previously you can set line item by looping through all the items one by one 
and then use record.setLineItemValue and set the value in line item's Field.

But in later released they remove this functionality and now you can not directly set the value of line items by simply looping through line items and setting value.

Now developer have to iterate the loop and for every line select that line and then set current line record.setCurrentLineItemValue(). This is same way as we are doing using UI, so on UI we first click on line i.e select in script and then change the value of line item i.e quivalent to setting current line item value.

If you want to add New Line :
record.selectNewLineItem('item'); record.setCurrentLineItemValue('item','item',itemid); record.setCurrentLineItemValue('item', 'quantity', 2); record.setCurrentLineItemValue('item', 'rate',294); //------- add all mandatory or necessary field's value here record.commitLineItem('item'); 

If you want to Update Line :

record.selectLineItem('item', lineno); 
record.setCurrentLineItemValue('item','item',itemid); 
record.setCurrentLineItemValue('item', 'quantity', 2); 
record.setCurrentLineItemValue('item', 'rate',294);
//------- add all mandatory or necessary field's value here 
record.commitLineItem('item');


 You can insert a new Line Also:

rec.insertLineItem('item', intCount + 1);
record.setCurrentLineItemValue('item','item',itemid); 
record.setCurrentLineItemValue('item', 'quantity', 2); 
record.setCurrentLineItemValue('item', 'rate',294);
//------- add all mandatory or necessary field's value here 
record.commitLineItem('item');
 
 
Please comment below if you have any suggestions.
 
Thanks
Abhi 

Comments