Unfortunately, it appears that when you create an Invoice from a custom transaction, NetSuite doesn't populate the native 'createdfrom' field. My attempt to work-around the issue by creating a custom reference field (i.e. custbody_invoicecreatedfrom) results in the getSublistValue() function returning an empty result, even through the internal ID is displayed correctly on the apply sublist line of the payment (XML). I tried using getSublistText() as well, but that didn't work either. I have no problem getting the native sublist values (i.e. record browser), but the custom field will not return a value. Any suggestions?
//Loop through all of the Invoices Applied to the Payment
for (var k = 0; k < invoiceCount; k++) {
var invoiceCreatedFrom = paymentSubmitted.getSublistValue({
sublistId: 'apply',
fieldId: 'custbody_invoicecreatedfrom',
line: k
});