0
votes

I have tried all manner of different ways to get this search to work properly. I even removed the filter to return values that I know the search returns. I then added the filter, and got different project ID's and verified the search (through the UI) did the job correctly.

It's a JOIN type search that should accept one parameter (project id) and return two pieces of data. That's it. Any ideas on why my parameter (filter) is not working the way it should?

var filter = new Array();
filter[0] = new nlobjSearchFilter('entityid', 'job', 'is', int_Project_ID);

var results = nlapiSearchRecord('transaction', 'customsearch_[...]', filter, null);

if ( !isNull(results) && results.length > 0 )

Here is a link to the criteria and results tabs of the search in NetSuite.

Imgur Link

1
Have you tried filtering on the Project's internalid instead of its entityid? - erictgrubaugh
Yes. I tried both interchangeably for a few times. It had to do with the 'job' in the filter. Also, the fact that I stored the expected parameter (project id) in the saved search. So, the answer was to change 'entityid' to 'internalid' and 'job' to 'jobmain' and to remove the parameter from the saved search in the UI. It now works. My boss had to actually help me figure this one out and even he was stumped for a while before finding the 'jobmain' thing. - Finnster

1 Answers

0
votes

try this to set the filters after loading search .

var filter = mySearch.filters;
                    var newfilters = [];
                    var filterss = {};
                    filterss.name = 'department';
                    filterss.operator = 'IS';
                    filterss.values = dep_fil;
                    filterss.join = 'employee';
                    filterss.summary = 'max';
                    newfilters.push(search.createFilter(filterss));
                    mySearch.filters = newfilters;


var searchResults = mySearch.run().getRange({
                    start : 0,
                    end : 500
                });

you can get the values by using

  searchResult.getValue({
                            name : 'email',
                            join : 'employee',
                            summary : 'max'
                        });

There are diffrent type of summary like max,sum,group etc I think the summmary is the reason.

note that this is suitescript 2 method.