title: Suitescript transform from Invoice to Customer Payment
body: <p>I've been trying to transform an "Invoice" to "Customer Payment" without any luck.  Here's the error I got when I test my script.</p>
  
  <pre><code>Account: 36714674
  Environment: SandBox
  Date &amp; Time: 7/23/2017 8:37 am
  Record Type: Sales Order
  Internal ID: 697645
  Execution Time: 0.00s
  Script Usage: 0
  Script: Tom Test Invoice
  Type: User Event
  Function: afterSubmit
  Error: JS_EXCEPTION
  {"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter value(s) for: Project, Department","stack":["anonymous(N/recordService)","afterSubmit(/SuiteScripts/tom_test_1.js:47)"],"cause":{"type":"internal error","code":"USER_ERROR","details":"Please enter value(s) for: Project, Department","userEvent":"aftersubmit","stackTrace":["anonymous(N/recordService)","afterSubmit(/SuiteScripts/tom_test_1.js:47)"],"notifyOff":false},"id":"","notifyOff":false}
  </code></pre>
  
  <p>Here's my suitescript code. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  define(["N/log", "N/email", "N/record", "N/render"], function(log, email, record, render) {
  
     
      function afterSubmit(scriptContext) {
        
       var newOrder = scriptContext.newRecord.id;
       
       
        var objRecord = record.transform({
              fromType: record.Type.SALES_ORDER,
              fromId: newOrder,
              toType: record.Type.ITEM_FULFILLMENT
          });
       
       var fid = objRecord.save();
        
       var objRecord2 = record.transform({
           fromType: record.Type.SALES_ORDER,
           fromId: newOrder,
           toType: record.Type.INVOICE,
           isDynamic: true,
       });
        
        var rid = objRecord2.save();
        
        var objRecord3 = record.transform({
           fromType: record.Type.INVOICE,
           fromId: rid,
           toType: record.Type.CUSTOMER_PAYMENT,
           isDynamic: true,
       });
        
        var rid3 = objRecord3.save();
    
      }
  
      return {
          afterSubmit: afterSubmit
      };
      
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>As you see in my code I first transform from "<strong>Sales Order</strong>" to "<strong>Fullfillment</strong>" and from "<strong>Sales Order</strong>" to "<strong>Invoice</strong>" and from "<strong>Invoice</strong>" to "<strong>Customer Payment</strong>".</p>
  
  <p>The part is not working is the transform from "<strong>Invoice</strong>" to "<strong>Customer Payment</strong>" </p>
  
  <p>According to the error, I don't know how and where to add the "<strong>Project</strong>" and "<strong>Department</strong>" to my code.</p>