Suite Deal
10/10/2023, 7:33 PMvar paymentObj = record.transform({
fromType: record.Type.INVOICE,
fromId: invoiceId,
toType: record.Type.CUSTOMER_PAYMENT,
isDynamic: true
});
console.log('Payment Transformed');
paymentObj.setValue({ fieldId: 'paymentoption', value: paymentMethod });
paymentObj.setValue({ fieldId: 'checknumber', value: checkNumber });
paymentObj.setValue({ fieldId: 'payment', value: paymentAmount }); //$40.00 GOOD
var lineCount = paymentObj.getLineCount({
sublistId: 'apply'
});
//GOOD
for (var i = 0; i < lineCount; i++) {
var lineInvoiceId = paymentObj.getSublistValue({ sublistId: 'apply', fieldId: 'internalid', line: i });
console.log('lineInvoiceId:', lineInvoiceId); //GOOD
console.log('invoiceId:', invoiceId); //GOOD
if(lineInvoiceId == invoiceId){
console.log('Line Invoice ID = Invoice ID'); //GOOD
paymentObj.selectLine({
sublistId: 'apply',
line: i
});
paymentObj.setCurrentSublistValue({ sublistId: 'apply', fieldId: 'apply', value: true});
paymentObj.setCurrentSublistValue({ sublistId: 'apply', fieldId: 'amount', value: paymentAmount });
paymentObj.commitLine({
sublistId: 'apply'
});
}
}
console.log('savingPayment')
var paymentId = paymentObj.save(); //CONSOLE ERROR = Transaction is not in balance! Line item sum of $0 does not equal applied amount of $40
Clay Roper
10/10/2023, 7:47 PMif(lineInvoiceId == invoiceId)
to make sure it's reaching this and updating the line you expect?Suite Deal
10/10/2023, 7:52 PMClay Roper
10/10/2023, 7:54 PMbattk
10/11/2023, 12:16 AM