Hey guys, how do you solve adding OR expressions w...
# suitescript
n
Hey guys, how do you solve adding OR expressions when adding search filters in script? (with search.createFilter) I found there's a propertyin the createFilter object called "isor" but doesn't have any effect when setting it to true as far as I can see..
s
You just create the filters like
[ search.createFilter(), 'OR', search.createFilter() ]
n
Ah ok, I tried pushing each search.createFilter() and then pushing "Or" after but got a strange error in the debugger.. will try to just create the whole filter rec before then and then adding it to the search object
s
If you looped and did that, you prob had a hanging
OR
at the end
just pop the end off
a
Like @Sandii mentioned you can do something like:
Copy code
var aFilters = [
    ['mainline', <http://search.Operator.IS|search.Operator.IS>, true],
    'AND',
    []
];

/* Getting the Array Position to Push the ORs conditions */
var nPos = aFilters.length -1;
parameters.sSONumbers.forEach(function (soNumber) {
    aFilters[nPos].push(['tranid', <http://search.Operator.IS|search.Operator.IS>, soNumber]);
    aFilters[nPos].push('OR');
});
aFilters[nPos].pop();
☝️ 1
n
@Sandii @alien4u Thanks guys, I solved it by adding OR manually and adding the filters manually old school way, worked fine 🙂