能否同时通过UI与SuiteScript 1函数添加筛选器并组合使用?
Can I Combine UI-Setup Filters with Additional SuiteScript 1 Filters for Item Searches?
Absolutely! You can absolutely combine UI-configured search filters with custom parameters added via SuiteScript 1—NetSuite handles this merging smoothly, and the final search results will respect both the UI-defined conditions and your script-added filters (they’re typically joined with an AND by default).
How to Implement This
Here’s a straightforward example of how to pull this off in SuiteScript 1:
- First, load your existing saved search that has UI-configured filters.
- Add your additional filters directly to the search object in your script.
- Run the search—NetSuite will automatically combine all filters.
// Load the saved search with UI-set filters var itemSearch = nlapiLoadSearch('item', 'customsearch_my_ui_item_search'); // Add a script-specific filter to exclude inactive items itemSearch.addFilter(new nlobjSearchFilter('isinactive', null, 'is', 'F')); // Add another filter to limit results to specific locations itemSearch.addFilter(new nlobjSearchFilter('location', null, 'anyof', ['2', '5'])); // Execute the combined search var searchResults = itemSearch.runSearch(); // Process your results here...
Important Things to Remember
- Default Filter Logic: All filters (UI + script) are joined with
ANDby default. If you need more complex logic (like mixingANDandOR), you can useitemSearch.setFilterLogic()to define a custom logic string (e.g.,1 AND (2 OR 3)where numbers correspond to filter positions). - Filter Overrides: If your script adds a filter that already exists in the UI search, the script’s filter will override the UI version. For example, if the UI has a filter for
inactive = Tand your script setsinactive = F, the script’s value will take priority. - Permissions: Ensure your script has access to the saved search (check the search’s permission settings and the script’s execution context to avoid access errors).
内容的提问来源于stack exchange,提问作者Ethan Freeman
相关产品推荐
相关产品推荐

