When doing search.load, I am trying to add more fi...
# suitescript
n
When doing search.load, I am trying to add more filters with the following code:
Copy code
salesOrderSearch.filters.push("AND", [["customer.internalid","anyof", companyid],
                    "OR",
                    ["customer.parent", "anyof", companyid]]);
However I get the following error: Cannot find function _clone in object AND.
s
I think you need to actually use the search.createFilter() call and push those in
As an example...
Copy code
var itemFilter = search.createFilter({
            name: 'item',
            operator: 'anyof',
            values: [item]
        });
        var locationFilter = search.createFilter({
            name: 'location',
            operator: 'anyof',
            values: [location]
        });
        var searchId = settingsObj.fields.somesearch;
        var someSearch = search.load({
            id: searchId 
        });
        someSearch.filters.push(itemFilter, locationFilter);
n
How would you do that @Sandii with expressions like OR
s
Never tried, but I would probably extract the filters from the old search and make a new one rather than appending to the original
or you could try pushing in an already formed array like
[[filterObj1, 'OR', filterObj2]]
n
Cool! @Sandii I think that worked. Thanks!
👍 1
s
this is good to see, as it used to be you couldn't modify the existing
filters
property on a search object.
180 Views