title: Programmatically create PAYMENT_VENDOR record in NetSuite?
body: <p>So, this is what I'm doing (hardcoding most values for now, just trying to learn NS):</p>
  
  <pre><code>    var vendorBillPayment = record.create({
              type: record.Type.VENDOR_PAYMENT,
              isDynamic: false,
              defaultValues: {
                  entity: 45
              }
          })
  
          vendorBillPayment.setValue({
              fieldId: 'entityname',
              value: "Superior ISP"
          })
  
          vendorBillPayment.setValue({
              fieldId: 'account',
              value: 129
          })
  
          vendorBillPayment.setValue({
              fieldId: 'currency',
              value: 1
          })
  
          vendorBillPayment.setValue({
              fieldId: 'customform',
              value: 45
          })
  
          vendorBillPayment.setValue({
              fieldId: 'exchangerate',
              value: "1.00"
          })
  
          var recordId = vendorBillPayment.save({
               enableSourcing: false,
               ignoreMandatoryFields: true
          })
  </code></pre>
  
  <p>Now, the problem begins in the snippet below, VendorPayment record has a sublist 'apply', which is a list of bills that the payment needs to apply.</p>
  
  <pre><code>        vendorBillPayment.setSublistValue({
              sublistId: 'apply',
              fieldId: 'internalid',
              line: 1,
              value: "303"
          });
  </code></pre>
  
  <p>The returned error is:</p>
  
  <pre><code>    error message:{"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":null,"stack":["anonymous(N/recordService)","&lt;anonymous&gt;(/SuiteScripts/..)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":null,"userEvent":null,"stackTrace":["anonymous(N/recordService)","&lt;anonymous&gt;(/SuiteScripts/..)"],"notifyOff":false},"id":"","notifyOff":false}
  </code></pre>
  
  <p>That is, not very useful message. I've been going over their documentation, but no win.</p>
  
  <p>EDIT: turns out that the apply sublist is of type list. This means, that one can NOT programmatically add/remove lines from that sublist. Just to edit the existing lines. </p>
  
  <p>Is there another way to programmatically pay the vendor bill, other than creating a VENDOR_PAYMENT record?</p>