Reputation: 79
I m very new to netsuite,i m trying to remove all line items in the latest existing sales order .How can i do this in UserEventAfterSubmit function. Thanks.
Upvotes: 1
Views: 3079
Reputation: 126
You can remove line items on client script, if you try to remove lines on user event, you need add other item.
in this case I remove items when the unit is in "EA".
function removeEa(){
jQuery("[id*='item_row_']").each(function(e) {
var line = jQuery(this).attr('id').split('item_row_')[1];
var unit = jQuery(this).children().text().indexOf('EA') != -1;
if(unit){
nlapiRemoveLineItem('item', line);
}
})
}
if you want remove lines in one user event you need add other line item is a new requirment for the new release.
Good luck
Upvotes: 0
Reputation: 2288
Use UserEventBeforeSubmit
instead of UserEventAfterSubmit
.
Try this :
var lineCount = nlapiGetLineItemCount('item');
for (var i = lineCount;i>=1; i--) {
nlapiRemoveLineItem('item', i);
}
Note
Make sure that the line items you want to delete must not associated with any transaction.
Upvotes: 3