title: Netsuite Restlet - Error Invalid Sublist Operation
body: <p>I am trying to script a work order completion in Netsuite but it is returning </p>
  
  <p>"SSS_INVALID_SUBLIST_OPERATION - You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist."</p>
  
  <p>Here is my code.</p>
  
  <pre><code>function preRequest(datain){
  //var id = 514752;
  //var sn = KQ0006608;
  var record = nlapiTransformRecord('workorder', datain.id, 'workordercompletion');
  record.setFieldValue('quantity', 1);
  
  
  var subrecord2=record.createSubrecord( 'inventorydetail');
  subrecord2.selectNewLineItem( 'inventoryassignment' );
  //subrecord2.selectLineItem('inventoryassignment', 1);   
  subrecord2.setCurrentLineItemValue('inventoryassignment', 'receiptinventorynumber', datain.sn);
  subrecord2.setCurrentLineItemValue('inventoryassignment', 'binnumber', 25);   
  subrecord2.setCurrentLineItemValue('inventoryassignment', 'quantity', 1);
  
  subrecord2.commitLineItem('inventoryassignment');
  
  subrecord2.commit();
  
  record.commitLineItem('inventorydetail');
  
  
  nlapiSubmitRecord(record);
  
  
  }
  </code></pre>
  
  <p>I have in good faith gone through their documentation and know what the error is and what might be causing it but I don't know how to fix the code so it will submit the record. Any help would be awesome!</p>
  
  <p>EDIT: Another clue is that Netsuite is treating the Quantity to Build field ('quantity' in my code) as a sublist. This is the root cause of the error. Fixing this will fix my code. Just not sure how.</p>
  
  <p>EDIT: See Work Order Completion UI page for reference.<a href="http://i.stack.imgur.com/TszDe.png" rel="nofollow">Work Order Completion UI Page</a></p>