title: Transform Sales Order to Invoice Netsuite
body: <p>I'm having trouble converting a sales order to an invoice order using suitescript. This is my code:</p>
  
  <pre><code>/**
   * @NApiVersion 2.x
   * @NScriptType UserEventScript
   * @NModuleScope SameAccount
   */
  define(['N/record'],
  function(record) {
      function afterSubmit(context) {
          var orderId = context.newRecord.id;
          var invoiceRecord = record.transform({
              fromType: record.Type.SALES_ORDER,
              fromId: orderId,
              toType: record.Type.INVOICE,
              isDynamic: true
          });
      }
  
      return {
          afterSubmit: afterSubmit
      };
  });
  </code></pre>
  
  <p>This is the error I'm getting:</p>
  
  <pre><code>Account: TSTDRV1714128
  Environment: Production
  Date &amp; Time: 6/28/2018 12:56 pm
  Record Type: Item Shipment
  Internal ID: 16547
  Execution Time: 0.00s
  Script Usage: 0
  Script: invoiceCreator
  Type: User Event
  Function: afterSubmit
  Error: JS_EXCEPTION
  {"type":"error.SuiteScriptError","name":"INVALID_INITIALIZE_REF","message":"You can not initialize invoice: invalid reference 16547.","stack":["createError(N/error)","afterSubmit(/SuiteScripts/UserEventScript.js:13)"],"cause":{"type":"internal error","code":"INVALID_INITIALIZE_REF","details":"You can not initialize invoice: invalid reference 16547.","userEvent":"aftersubmit","stackTrace":["createError(N/error)","afterSubmit(/SuiteScripts/UserEventScript.js:13)"],"notifyOff":false},"id":"","notifyOff":false}
  </code></pre>
  
  <p>I've seen some sample solutions for this problem but I still keep getting the same error. Help would be greatly appreciated.</p>