NetSuite Development Notes
Friday, October 12, 2018
Reliably select the correct line item and set field values when iterating through a sublist using client scripts.
To reliably select the correct line and set values to fields when iterating through a sublist using client scripts, use this sample code as guide:
var itemCount = 0; itemCount = nlapiGetLineItemCount('item');if(itemCount > 0){ for(i = 1; i <= itemCount; i++){ //enclose nlapiSelectLineItem in a 'try' block to ensure possible errors generated are catched. try{ nlapiSelectLineItem('item',i); } finally{ //If selected line is blank then cancel selected line and perform nlapiSelectLineItem again. if(nlapiGetCurrentLineItemValue('item','item') == ''){ nlapiCancelLineItem('item'); nlapiSelectLineItem('item',i); } } //set field values and commit the line nlapiSetCurrentLineItemValue('item','price','2',true,true); nlapiCommitLineItem('item'); } }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment