I'm converting a reeeeaaally old 1.0 scheduled scr...
# suitescript
k
I'm converting a reeeeaaally old 1.0 scheduled script that I'd inherited to a map reduce, so some of this isn't the way I'd do it if done from scratch and will probably clean it up a bit.
j
In my experience you need to reassign the filterExpression object for it to work properly.
Copy code
const filterExprCopy = mrr_np.filterExpression;
// modify your copy using push etc;
mrr_np.filterExpression = filterExprCopy; // now it will use your new filters
This is because, last I checked, NetSuite implemented filterExpression as a getter / setter of an internal private array, rather than direct access to it. The getter produces a copy of that array. So if you just do
Copy code
mrr_np.filterExpression.push(...)
that is only working on the copy and not the internal array.
So if you only add your filters to the copy, it is not using your filters when you run the search. This will cause your map/reduce to operate on more records than you intended.
k
I'll try that, thanks