Luis
08/23/2024, 4:36 PMCeligo AI
08/23/2024, 4:36 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems like you can replicate the process of going to a customer, clicking "accept payment", going to the apply tab > invoice tab, selecting a journal, then going to the credits tab and selecting a payment and then save, in SuiteScript by using the
record.transform
method to mimic the effect of the Accept Payment
button. Then, you can use Record.setSublistValue
to mark the same checkboxes you would in the UI. This will usually involve using Record.findSublistLineWithValue
or Record.getSublistValue
to find which line you want to mark.
Here is a simplified example of how you might do this:
javascript
var record = require('N/record');
var customerPayment = record.transform({
fromType: record.Type.INVOICE,
fromId: '123',
toType: record.Type.CUSTOMER_PAYMENT,
});
customerPayment.setValue({
fieldId: 'customer',
value: '123',
});
var lineCount = customerPayment.getLineCount({ sublistId: 'apply' });
for (var i = 0; i < lineCount; i++) {
customerPayment.selectLine({ sublistId: 'apply', line: i });
customerPayment.setCurrentSublistValue({ sublistId: 'apply', fieldId: 'apply', value: true });
customerPayment.commitLine({ sublistId: 'apply' });
}
customerPayment.save();
This code transforms an invoice into a customer payment, sets the customer, and then loops through the 'apply' sublist, marking each line as applied. Finally, it saves the customer payment.
******
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
08/23/2024, 4:37 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85746032
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85479337
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839971721
Celigo AI
08/23/2024, 4:37 PM