HOW TO PREVENT ERRORS WHEN DELETING SUBLIST ROWS USING SCRIPT IN NETSUITE? -NETSUITE ACADEMY

While trying to delete any sublist row, the row with the highest line number must be deleted first. For eg: if there are 5 lines with line number 1,2,3,4 and 5. Suppose you want to delete 3rd and 5th line item.

If you delete the 3rd row first using nlapiRemoveLineItem('item, 3), then there are only 4 lines remaining and using nlapiRemoveLineItem('item, 5) will throw error.


So, the solution is to delete the 5th row first and then delete the 3rd row. See the example code below:


var line_count = nlapiGetLineItemCount('item');


for(var k=line_count;k>=1;k--)// loop starting with last line

{



if(k==5||k==3)



nlapiRemoveLineItem('item, k);



}








For Netsuite Training (Including training for interviews), Support, Implementation contact us at:




Email : netsuiteacademy@netsuite-academy.com

Facebook page : https://www.facebook.com/Netsuite-Academy-1591053827660082/


Comments

Popular posts from this blog

Work Around the 1000 Row Limit Returned by Saved Searches in Netsuite

USING CASE (IF AND ELSE) IN NETSUITE SAVED SEARCH- NETSUITE ACADEMY

Understand Core Technology behind SuiteScript 2.0