Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SuiteScript 2.0 Add filters to saved search in script

I have a custom record that has a field for an item and a field for location. I have a saved search on that record that already has the columns I want and some beginning criteria that will always be needed. I want to use this search when I am on a Sales Order. I want to store an array of all the item internal ids and location ids on the lines and then pass that as a dynamic filter to this search in SuiteScript 2.0.

According to the documentation this can be done. On the search.Filter page it says "You create a search filter object with search.createFilter(options) and add it to a search.Search object that you create with search.create(options) or load with search.load(options)." However, I do not see any parameter on search.load for this nor a code example of adding it after the load. All examples of using search.Filter are in using it in the search.create function

Thank you for any help you can give.

like image 747
TMann Avatar asked Nov 30 '17 16:11

TMann


People also ask

How do I create a saved search in NetSuite by script?

To create a saved search, you will first define all search criteria and then execute the search using nlapiCreateSearch(type, filters, columns). The search will not be saved until you call the nlobjSearch. saveSearch method.

How do you write SuiteScript in NetSuite?

In Visual Studio Code, open the SuiteCloud project that you want to create the SuiteScript file in. Open the Command Palette and enter suitecloud . From the dropdown list, select SuiteCloud: Create SuiteScript File. From the dropdown list, select the type of SuiteScript file type you want to create and press Enter.


1 Answers

You can push the filter object to the filters property of the search.

searchObj.filters.push(filterObj);
like image 171
Maria Berinde-Tampanariu Avatar answered Sep 21 '22 03:09

Maria Berinde-Tampanariu