Luis
02/05/2025, 1:47 PMCeligo AI
02/05/2025, 1:47 PMAI generated answer (using internal Slack threads):To get the sales orders of a specific customer with its id and also the id and quantity of the items in the transaction using the query module, you can use the following SuiteScript snippet:
javascript
var query = require('N/query');
function getSalesOrders(customerId) {
    var salesOrderQuery = query.create({
        type: query.Type.SALES_ORDER
    });
    var customerFilter = query.createCondition({
        fieldId: 'entity',
        operator: query.Operator.ANY_OF,
        values: [customerId]
    });
    salesOrderQuery.condition = customerFilter;
    var salesOrderResultSet = salesOrderQuery.run();
    var salesOrders = [];
    salesOrderResultSet.each(function(result) {
        var salesOrder = {
            id: result.getValue({name: 'id'}),
            items: []
        };
        var itemResultSet = result.getSublist({
            name: 'item'
        });
        itemResultSet.each(function(itemResult) {
            salesOrder.items.push({
                id: itemResult.getValue({name: 'item'}),
                quantity: itemResult.getValue({name: 'quantity'})
            });
            return true;
        });
        salesOrders.push(salesOrder);
        return true;
    });
    return salesOrders;
}iditemsidquantityentityiditemquantityCeligo AI
02/05/2025, 1:47 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832246184
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829600215
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828606904
Celigo AI
02/05/2025, 1:47 PM