Answer:
The sample code below illustrates how a developer can read through records on the Apply sublist on a Customer Payment Record:
// Load the Customer Payment Record
var custPaymentRec = nlapiLoadRecord('customerpayment', 270);
// Get the line item cound of the apply sublist
var applySublitsCount = custPaymentRec.getLineItemCount('apply');
// Iterate over the Apply sublist
for (var i = 0; i < applySublitsCount; i++) {
// Get the 'doc' field on the line item on the Apply sublist. This is the internal of the record.
var recID = custPaymentRec.getLineItemValue('apply', 'doc', i+1)
// Get the type of the line item
var lineItemType = custPaymentRec.getLineItemValue('apply', 'type', i+1)
// Load the record
if(lineItemType == 'Invoice'){
var invoiceRecord = nlapiLoadRecord('invoice',recID);
}else if(lineItemType == 'Journal'){
var invoiceRecord = nlapiLoadRecord('journalentry',recID);
}
}
No comments:
Post a Comment