Aaron McCausland
03/27/2025, 7:13 PMCeligo AI
03/27/2025, 7:13 PMAI generated answer (using internal Slack threads):In SuiteScript 2.x, there isn't a single function or method that directly gets the sum of the "amount" column for all Items in a transaction or Opportunity record. However, you can achieve this by iterating over the line items in the record and summing the amounts manually. Here is a sample code snippet that demonstrates this:
javascript
var record = require('N/record');
var transactionId = '123'; // replace with your transaction id
var myRecord = record.load({
    type: record.Type.SALES_ORDER, 
    id: transactionId
});
var lineCount = myRecord.getLineCount({sublistId: 'item'});
var totalAmount = 0;
for (var i = 0; i < lineCount; i++) {
    var lineAmount = myRecord.getSublistValue({
        sublistId: 'item',
        fieldId: 'amount',
        line: i
    });
    totalAmount += lineAmount;
}
log.debug('Total Amount', totalAmount);record.Type.SALES_ORDERCeligo AI
03/27/2025, 7:14 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83066988
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830075562
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.827760279
Celigo AI
03/27/2025, 7:14 PM