So, this is what I'm doing (hardcoding most values for now, just trying to learn NS):
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
})
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.
vendorBillPayment.setSublistValue({
sublistId: 'apply',
fieldId: 'internalid',
line: 1,
value: "303"
});
The returned error is:
error message:{"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":null,"stack":["anonymous(N/recordService)","<anonymous>(/SuiteScripts/..)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":null,"userEvent":null,"stackTrace":["anonymous(N/recordService)","<anonymous>(/SuiteScripts/..)"],"notifyOff":false},"id":"","notifyOff":false}
That is, not very useful message. I've been going over their documentation, but no win.
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.
Is there another way to programmatically pay the vendor bill, other than creating a VENDOR_PAYMENT record?