Usage of Saved Search in Map/Reduce Scripts Without running it directly in getInputData()

When working with Map/Reduce scripts, a simplified approach can be to directly create the saved search object and return it. This method avoids unnecessary overhead and aligns with best practices for governance limits.

Here’s an example using the search.create() method in the getInputData() stage:

define(['N/search'], function(search) {
    function getInputData() {
        return search.create({
            type: search.Type.SALES_ORDER,
            filters: [['status', search.Operator.ANYOF, 'SalesOrd:F']],
            columns: ['internalid', 'tranid']
        });
    }


    return { getInputData };
});

By simply returning the search object, subsequent stages like map and reduce can efficiently handle the search results. This approach enhances code simplicity and avoids fetching data upfront, making it an excellent choice for scalability.

Leave a comment

Your email address will not be published. Required fields are marked *