jdcaliff jdcaliff - 19 days ago 8
Javascript Question

How to set up user to control Saved Search Criteria in NetSuite Suitelet SSv2

I am trying to set up a Suitelet to give the user the option of adjusting the criteria of a saved search. I have set up search with ID customsearch_ca_export_detail_search__38 and I would like to be able to control the criteria of this search within the Suitelet. I would prefer to use SSv2 but I am not finding instructions for this in the documentation. How do I do this?

Thanks,


  • Jesse


Answer
/**
*@NApiVersion 2.x
*/

require(['N/search'], function(search) {

    function loadSearchAndAddFilter() {

        var searchObj = search.load({
            id: 'customsearch_ca_export_detail_search__38'
        });

        var filters = searchObj.filters;

        var filter = search.createFilter({
            // create new filter here
        });

        filters.push(filter);
        searchObj.filters = filters;

        searchObj.run().each(function(result) {
            // access search results here
            return true;
        });
    }

    loadSearchAndAddFilter();
});
Comments