title: Netsuite RESTlet - nlapiSubmitRecord() return null when create sales order containing assembly items
body: <p>When I send rest call to Netsuite and create a new sales order via RESTlet, I found that my code could work perfectly if the sales order 'item' field only contains inventoryitems. However, when the sales order contains assemblyitem or kit/package item, the nlapiSubmitRecord() function will return null and no sales order will be created. (No error is thrown as well)
  Could anyone please tell me the reason? Thanks!</p>
  
  <p>My RESTlet function to create a new sales order is as follows:</p>
  
  <pre><code>function createSalesorder(datain) {
      // init message and sales order obj
      var message = new Object();
      var record = nlapiCreateRecord('salesorder'); 
      // check if the sales order already exists in Netsuite
      if(!datain['otherrefnum']){
          message.status = 'failed',
          message.message = 'missing Customer P.O.';
          return message;
      } else {
          var filters = new Array();
          var columns = new Array();
          filters.push(new nlobjSearchFilter('otherrefnum', null, 'equalto', datain['otherrefnum']));
          filters.push(new nlobjSearchFilter('entity', null, 'is', datain['entity']));
          // columns.push(new nlobjSearchColumn('otherrefnum', null, null));
          var search = nlapiSearchRecord(datain.recordtype, null, filters, columns);
          if(search &amp;&amp; search.length&gt;0){
              message.status = 'duplicated',
              message.id = search[0].id;
              return message;
          }
      }
      // check input data has required fields
      if(!datain['item']){
          message.status = 'failed';
          message.message = 'missing item';
          return message;
      }
      if(!datain['entity']){
          message.status = 'failed';
          message.message = 'missing customer id';
          return message;
      }
      // init fields with default values
      if(!datain['custbody_shipping_reason']){
          record.setFieldValue('custbody_shipping_reason',1);
      }
      if(!datain['custbody_order_type']){
          record.setFieldValue('custbody_order_type',1);
      }
      if(!datain['shipmethod']){
          record.setFieldValue('shipmethod', 4304);
      }
      if(!datain['location']){
          record.setFieldValue('location', 21);
      }
      if(!datain['istaxable']){
          record.setFieldValue('taxitem', -8);
      }
      // load data input
      for(var fieldname in datain){
          switch(fieldname){
              case 'recordtype':
              case 'type':
              case 'id':
                  break;
              case 'istaxable':
                  record.setFieldValue(fieldname, datain[fieldname]);
                  if(datain[fieldname] == 'T') record.setFieldValue('taxitem', 2908);
                  else record.setFieldValue('taxitem', -8);
              case 'item':
                  for(var i = 0; i &lt; datain[fieldname].length; i++){
                      for(var itemfield in datain[fieldname][i]){
                          record.setLineItemValue('item', itemfield, i+1, datain[fieldname][i][itemfield]);
                      }
                  }
                  break;
              default:
                  record.setFieldValue(fieldname, datain[fieldname]);
                  break;
          }
      }
      // submit record
      var recordID = nlapiSubmitRecord(record, true);
      nlapiLogExecution('DEBUG', 'Create a new salesorder, id = '+recordID);
      // return results
      message.status = 'create';
      message.id = recordID;
      var order_entity = nlapiLoadRecord('salesorder', message.id);
      message.refid = order_entity.getFieldValue('tranid');
      return message;
  }
  </code></pre>
  
  <p>Update 1: I tried to run the same code in Netsuite debugger, it turns out to successfully write the sales order, besides that is came up with a warning:</p>
  
  <pre><code>warning Items on this line have been drop shipped or special ordered. Are you sure you want to modify it?
  </code></pre>
  
  <p>Not sure if this is the issue that prevents me to save the sales order properly in production mode.</p>