title: Netsuite - Transfer Inventory error
body: <p>I have been using NetSuite for only a short time, and already hate it. I am sorry if this is a stupid question, but I haven't been able to find an answer so far, either in the Netsuite docs, StackOverflow or other websites. In fact, the answers I found have resulted in an error.</p>
  
  <p>My company requires a script to transfer inventory based on an EDI input file. Reading the file is no problem, even parsing it is working. However, actually inserting the data is proving problematic.
  I have been able to insert normal records, but Inventory Transfer records are giving me problems.</p>
  
  <p>From Stack Overflow I found and adapted some code into the following:</p>
  
  <pre><code>var xfer = nlapiCreateRecord("inventorytransfer");
  
  xfer.setFieldValue("trandate", FormatDate("20160101"));
  xfer.setFieldValue("location", 9);
  xfer.setFieldValue("transferlocation", 9);
  
  nlapiSelectNewLineItem('invt');
  nlapiSetLineItemValue("invt","invtid",1, 189);
  nlapiSetLineItemValue("invt","adjustqtyby", 1, "5");
  nlapiCommitLineItem('invt');
  
  var id = nlapiSubmitRecord(xfer);
  </code></pre>
  
  <p>The FormatDate function just exchanges the date from the text file into a system date NetSuite can understand.</p>
  
  <p>However, when I run this code I get the following error:</p>
  
  <blockquote>
    <p>USER_ERROR: You must enter at least one line item for this transaction.</p>
  </blockquote>
  
  <p>I thought inserting the line item was the reason to use nlapiSelectNewLineItem, but I guess not. Also nlapiCreateNewLineItem doesn't seem to exist.</p>
  
  <p>The values I am inserting are all just test data, as I'm testing this in the debugger. Location 9 exists, as does item 189.
  My full script finds these id's based on string values from the text files. But since this is the section that doesn't work I have set it apart to test.</p>
  
  <p>Can anyone help with this?</p>