Bellamy Bellamy - 7 months ago 71
Javascript Question

Netsuite search filter conditions not working

I'm doing a Netsuite search but the filters do not actually do any filtering? The "budgetimport" object has 314 items in it, and no matter how I attempt to filter the search, all 314 items are returned every time.

What am I missing / doing wrong?

Thanks in advance.

P.S. Whilst I'm here: what's the "best" way to get the value in the 'amount' column from the search? (There should only be one item returned from the search, but what if there are more?)

//add search columns
var columns = [];
columns.push(new nlobjSearchColumn('year'));
columns.push(new nlobjSearchColumn('department'));
columns.push(new nlobjSearchColumn('account'));
columns.push(new nlobjSearchColumn('amount'));

//add search filters
var filters = [];
filters.push(new nlobjSearchFilter('year', null, 'anyof', 'FY 2007', null));
filters.push(new nlobjSearchFilter('department', null, 'anyof', 'Bass', null));
filters.push(new nlobjSearchFilter('account', null, 'anyof', 'Administration Expenses', null));

//execute the search
var search = nlapiSearchRecord('budgetimport', null, filters, columns);


After a lot of playing and much frustration, the problem lies with the "non-standard" object in NetSuite, so "normal" methods of doing things don't apply.

To filter on the budgetimport object, you need to use "formulatext" and set you filter on that, e.g.

//add search filters
var filters = [];
filters.push(new nlobjSearchFilter('formulatext', null, 'is', fiscalyear).setFormula('{Year}')); //NOTE : Capital 'Y' in Year
filters.push(new nlobjSearchFilter('formulatext', null, 'is', costcentre).setFormula('{department}'));