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

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

AS a netsuite solution provider 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 are doing netsuite customization and want to 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 netsuite implementation 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);

}

Feel free to reach out TheSmilingCoders for proper netsuite implementationnetsuite consultation , netsuite customization, netsuite Support,netsuite Trainingcontact us at:

Email : [email protected]

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/


Log out of this account

Leave a Reply