title: Transform sales order to invoice error
body: <p>I'm having an error when I try to transform a newly created sales order to an invoice.</p>
  
  <p>Here's my code: </p>
  
  <pre><code>  define(["N/log", "N/email", "N/record"], function(log, email, record) {
  
      function afterSubmit(scriptContext) {
  
          var newOrderId = scriptContext.newRecord.id;
  
          var objRecord = record.transform({
              fromType: record.Type.SALES_ORDER,
              fromId: newOrderId,
              toType: record.Type.INVOICE,
              isDynamic: true
          });
  </code></pre>
  
  <p>Here's the error details:</p>
  
  <pre><code>Account: 3671783
  Environment: SandBox
  Date &amp; Time: 6/28/2017 2:09 am
  Record Type: Sales Order
  Internal ID: 668978
  Execution Time: 0.00s
  Script Usage: 0
  Script: test send invoice
  Type: User Event
  Function: afterSubmit
  Error: JS_EXCEPTION
  {"type":"error.SuiteScriptError","name":"INVALID_INITIALIZE_REF","message":"You can not initialize invoice: invalid reference 668978.","stack":["createError(N/error.js)","afterSubmit(/SuiteScripts/sendinvoice1.js:23)"],"cause":{"type":"internal error","code":"INVALID_INITIALIZE_REF","details":"You can not initialize invoice: invalid reference 668978.","userEvent":"aftersubmit","stackTrace":["createError(N/error.js)","afterSubmit(/SuiteScripts/sendinvoice1.js:23)"],"notifyOff":false},"id":"","notifyOff":false}
  </code></pre>
  
  <p>I don't know what am I doing wrong.</p>