Filter expressions cannot include Filter Objects. This is very important. If you decide to form your filters with Filter Expression, you use array of string arrays. The following syntax is wrong:
// WRONG!!!
var f1 = search.createFilter({
name: 'mainline',
operator: search.Operator.IS,
values: 'T'
});
var f2 = search.createFilter({
name: 'type',
operator: search.Operator.ANYOF,
values: ['VendBill','VendCred']
});
// here you will receive an error message
var s = search.create({
type : 'transaction',
filters : [ f1, 'and', f2 ] // f1,f2 are Filter Objects, instead of string arrays
});
Instead, use the correct:
// CORRECT!!!
var f1 = ['mainline', search.Operator.IS, 'T'];
var f2 = ['type', search.Operator.ANYOF, ['VendBill','VendCred'] ];
var s = search.create({
type : 'transaction',
filters : [ f1, 'and', f2 ]
});
or if you want to keep with Filter Objects approach, pass an array of filter objects, and forget about operators 'AND', 'OR', 'NOT'. It will be always AND
// correct, but not useful
var f1 = search.createFilter({
name: 'mainline',
operator: search.Operator.IS,
values: 'T'
});
var f2 = search.createFilter({
name: 'type',
operator: search.Operator.ANYOF,
values: ['VendBill','VendCred']
});
var s = search.create({
type : 'transaction',
filters : [ f1, f2 ] // here you have array of Filter Objects,
// filtering only when all of them are TRUE
});