0
votes

I have a Transaction's saved search on my Netsuite account and this saved search has some filter condition on Netsuite UI.

Using SuiteScript 2.0, I am loading this search and taking copy of all the filter defined on Netsuite UI (say defaultfilters) and then applying filter for "trandate" as filterExpression then pushing defaultfilters in savedsearch filter collection.

but what happening is that, netsuite only considering "trandate" filter, not those that are defined on Netsuite.

I assume that somehow between two filters "OR" logical operator being applied.

same issue discussed in another query: SuiteScript 2.0 search.createFilter with formula not working

please guide me for this issue.

Thanks

1

1 Answers

2
votes

You can do the following to add searchFilters or FilterExpressions

  1. Load the search

    var savedSearch = search.load({ id: SEARCH_ID });

  2. Push custom filters in savedSearch object as below:

    // for searchFilter
    savedSearch.filters.push(search.createSearchFilters(SEARCH_FILTER_OBJECT);
    
    // for filter expression
    var filterExpressions = savedSearch.filterExpressions;
    filterExpressions.push('and', [FIELDID, SEARCH_OPERATOR, VALUES]);
    savedSearch.filterExpressions = filterExpressions;
    

As for using formula in filterExpressions, if you use formulanumeric as the fieldName, your operator should be equalto and not is whereas if you use formulatext as fieldName you can use is operator as per NetSuite's Search Operators