Mike Casey
01/15/2025, 9:19 PMCeligo AI
01/15/2025, 9:19 PMAI generated answer (using internal Slack threads):Based on the conversations, here is a client-side SuiteScript 2.0 that looks for all the related records associated with a sales order and filters return authorizations from the related records:
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */
define(['N/search'], function(search) {
    function findRelatedRecords() {
        var salesOrderId = 'YOUR_SALES_ORDER_ID'; // replace with your sales order id
        var mySearch = search.create({
            type: search.Type.SALES_ORDER,
            columns: ['internalid', 'tranid', 'statusref', 'status'],
            filters: [
                ['type', 'anyof', 'SalesOrd'],
                'AND',
                ['mainline', 'is', 'T'],
                'AND',
                ['internalid', 'anyof', salesOrderId]
            ]
        });
        mySearch.run().each(function(result) {
            var relatedRecords = result.getSublistValues({
                sublistId: 'recmachcustrecord_related_sales_order'
            });
            relatedRecords.forEach(function(relatedRecord) {
                if (relatedRecord.recordType === 'returnauthorization') {
                    // process return authorization record
                    console.log('Return Authorization: ' + relatedRecord.id);
                }
            });
            return true; // continue to next sales order
        });
    }
    return {
        pageInit: findRelatedRecords
    };
});Celigo AI
01/15/2025, 9:19 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830882847
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829370797
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828435063
Celigo AI
01/15/2025, 9:19 PM