Rywin Shyrr Costales
02/12/2025, 10:20 PMbattk
02/12/2025, 11:25 PMRywin Shyrr Costales
02/13/2025, 12:38 AM// Transform the Customer Deposit into a Deposit Application
var depositAppRec = record.transform({
fromType: record.Type.CUSTOMER_DEPOSIT,
fromId: depositId,
toType: record.Type.DEPOSIT_APPLICATION,
});
var sublists = depositAppRec.getSublists();
log.debug('Available Sublists', sublists);
// Loop through the 'apply' sublist to find the correct invoice
var lineCount = depositAppRec.getLineCount({sublistId: 'apply'});
log.debug('lineCount',lineCount);
for (var i = 0; i < lineCount; i++) {
var appliedInvoiceId = depositAppRec.getSublistValue({
sublistId: 'apply',
fieldId: 'internalid',
line: i
});
log.debug("appliedInvoiceId",appliedInvoiceId);
log.debug("invoiceId",invoiceId);
if (appliedInvoiceId == invoiceId) {
// depositAppRec.selectLine({ sublistId: 'apply', line: i });
depositAppRec.setSublistValue({
sublistId: 'apply',
fieldId: 'apply',
value: true,
line : i
});
depositAppRec.setSublistValue({
sublistId: 'apply',
fieldId: 'amount',
value: amountToApply,
line : i
});
// depositAppRec.commitLine({ sublistId: 'apply' });
log.debug('Invoice Applied', 'Invoice ID: ' + invoiceId + ', Applied Amount:' + amountToApply);
break; // Stop loop after applying the correct invoice
}
}
var depositAppId = depositAppRec.save();
battk
02/13/2025, 12:50 AMbattk
02/13/2025, 12:51 AMbattk
02/13/2025, 12:51 AMRywin Shyrr Costales
02/13/2025, 12:52 AM