Load a Search for Sales Order Records and Return the First 100 Search Results

The following sample loads and runs a saved search for sales order records. The sample obtains the first 100 rows of search results.

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
 * @NApiVersion 2.x
 */

require(['N/search'], function(search) {
    function runSearchAndFetchResult() {
        var mySearch = search.load({
            id: 'customsearch_my_so_search'
        });

        var searchResult = mySearch.run().getRange({
            start: 0,
            end: 100
        });
        for (var i = 0; i < searchResult.length; i++) {
            var entity = searchResult[i].getValue({
                name: 'entity'
            });
            var subsidiary = searchResult[i].getValue({
                name: 'subsidiary'
            });
        }
    }

    runSearchAndFetchResult();
}); 

        

General Notices