search - Netsuite getting the display text for a formula -
i in need of getting text (display) value of field compare date ranges on posting period. have formula below pushing in filter array other filters need run
var columns = []; columns.push(new nlobjsearchcolumn('transactionnumber')); columns.push(new nlobjsearchcolumn('line')); columns.push(new nlobjsearchcolumn('item')); columns.push(new nlobjsearchcolumn('account')); columns.push(new nlobjsearchcolumn('amount')); columns.push(new nlobjsearchcolumn('vsoeallocation')); columns.push(new nlobjsearchcolumn('postingperiod')); columns.push(new nlobjsearchcolumn('srctranpostperiod','revrecschedule')); columns.push(new nlobjsearchcolumn('recuramount','revrecschedule')); columns.push(new nlobjsearchcolumn('jedoc', 'revrecschedule')); columns[0].setsort(); columns[1].setsort(); var filter = []; var formula = "case when to_date({postingperiod.displayname}, 'mon yyyy') >= " + newselecteddate.getfullyear() + " 1 else 0 end"; filter.push(new nlobjsearchfilter('revrecenddate', null, 'after', newselecteddate)); filter.push(new nlobjsearchfilter('type', null, 'anyof', ['custinvc', 'cashsale'])); filter.push(new nlobjsearchfilter('templatename','revrecschedule','isnotempty')); filter.push(new nlobjsearchfilter('deferredamount','revrecschedule','isnot', 0)); filter.push(new nlobjsearchfilter('formulanumeric', null, 'equalto', 1).setformula(formula)); var search = nlapicreatesearch('transaction', filter, columns); var searchresult = search.runsearch();
which in theory work except gets value of field instead of text (it turns out non date value). know there ways once have ran search text instead of value (nlobjsearchresult.gettext) have not found way within formula.
any ideas?
it seems posting period might contain additional information apparently used in functions to_date(). may because of internal hierarchy of accounting periods. or might because periods list/record fields in single select box, there id every posting period. around this, i've done following (applied code):
var formula = "case when to_date(substr({postingperiod},-8,8), 'mon yyyy') >= " + newselecteddate.getfullyear() + " 1 else 0 end";
which adding substr function pick last 8 characters in string pass onto date function.
Comments
Post a Comment