Martin
06/10/2025, 6:34 PMCeligo AI
06/10/2025, 6:34 PMAI generated answer (using internal Slack threads):To initialize a credit memo with specific invoices applied in SuiteScript, you can use the
record.transform
method to transform an invoice to a customer payment. This is similar to the 'Accept Payment' button in the UI. Here is a simplified example:
javascript
var invoiceId = '123'; // replace with your invoice internal id
var invoiceRecord = record.load({
type: record.Type.INVOICE,
id: invoiceId
});
var customerPaymentRecord = record.transform({
fromType: record.Type.INVOICE,
fromId: invoiceId,
toType: record.Type.CUSTOMER_PAYMENT
});
// Loop through the apply sublist and select the records to apply the payment to
for (var i = 0; i < customerPaymentRecord.getLineCount({sublistId: 'apply'}); i++) {
customerPaymentRecord.selectLine({sublistId: 'apply', line: i});
customerPaymentRecord.setCurrentSublistValue({sublistId: 'apply', fieldId: 'apply', value: true});
customerPaymentRecord.commitLine({sublistId: 'apply'});
}
var customerPaymentId = customerPaymentRecord.save();
This script loads an invoice record, transforms it into a customer payment record, and then loops through the 'apply' sublist to select the invoices to apply the payment to. Finally, it saves the customer payment record.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
06/10/2025, 6:34 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.853342295
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.843731403
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840375543
Celigo AI
06/10/2025, 6:34 PM