NetSuite and / or filter

I am trying to create a report in NetSuite. I want to filter certain data by one parameter, then I want to filter data using another parameter. Does NetSuite have an AND / OR filter?

+4
source share
4 answers

If you do this using the Netsuite Report / search interface, click Use Advanced Search , and then select Use Expressions . You will see the AND / OR column on the Criteria tab.

If you do this using Suit Script, use search filter expressions

//Define search filter expression
var filterExpression = [ 
   [ 'trandate', 'onOrAfter', 'daysAgo90' ],
   'or',
   [ 'projectedamount', 'between', 1000, 100000 ],
   'or',
   'not', [ 'customer.salesrep', 'anyOf ', -5] 
];
+5
source

, .
: → → →
" ". "And/or".

:
var filters = new Array(); [0] = nlobjSearchFilter ('custrecord01', null, 'contains', 'alpha'). setOr (true);
[1] = nlobjSearchFilter ('custrecord02', null, 'contains', 'x'). setOr (true);

+2

sql OR ,

var flt = new Array();
var strFormula = "case when {internalid}=123 OR {internalid}=456 then 'yes' else 'no' end";
flt.push(new nlobjSearchFilter('formulatext',null,'is','yes').setFormula(strFormula));

var col = new Array();
col.push(new nlobjSearchColumn("entityid"));

var rslt = nlapiSearchRecord('customer',null,flt,col);
+2
source

I came across a situation where I need to use the AND / OR filter in Netsuite. I have achieved this:

You can directly set the value of the static filter

filters: [
    ['internalid', 'anyof', parseInt(customer_internal_id)],
    'and',
    ['transaction.internalidnumber', 'equalto', parseInt(salesorder_internal_id)],
    'and',
    ['transaction.mainline', 'is', 'true']
]

If you want to add a filter dynamically , you store / click your filter on the array and set this array as a filter. You can achieve this with

var individualFilter = [], combineIndividualFilter = [], defaultFilters = [];
for (var i = 0; i < numLines; i++) {
    individualFilter[0] = ['formulatext: {category}','startswith',"Related Items for "+ itemName[i].split(" :")[0]];
    combineIndividualFilter.push(individualFilter[0]);
    if ((i + 1) != numLines) {
        combineIndividualFilter.push('OR');
    }
}
defaultFilters.push(combineIndividualFilter);
defaultFilters.push('AND');
defaultFilters.push(['website', 'anyof', 3 ]);
defaultFilters.push('AND');
defaultFilters.push(['formulatext: {storedisplayimage}','isnotempty', null ]);

and finally setting

filters : defaultFilters
+2
source

Source: https://habr.com/ru/post/1525885/


All Articles