NetSuite API | operator undefined for search

Author - Neha Mishra

On filtering contacts coming from Netsuite CRM based on last modified date, gives error “operator undefined for search”:

Below is the code that retrieves all the contacts from Netsuite CRM:

ContactSearch custSearch = new ContactSearch();
ContactSearchBasic custSearchBasic = new ContactSearchBasic();
custSearch.setBasic(custSearchBasic);
SearchResult result = _port.search(custSearch);

To filter I added criteria to the “custSearchBasic” before searching:

SearchDateField lastModifiedDate = new SearchDateField();
Calendar cal = new GregorianCalendar();       
cal.setTime(new Date(lastModified));   (Where, lastModified is the timestamp)
lastModifiedDate.setSearchValue(cal);
custSearchBasic.setLastModifiedDate(lastModifiedDate);

Solution:

I had not passed a specific operator (SearchDateFieldOperator.after) to the search field which is compulsory.
SearchDateField lastModifiedDate = new SearchDateField();
lastModifiedDate.setOperator(SearchDateFieldOperator.after);
Calendar cal = new GregorianCalendar();       
cal.setTime(new Date(lastModified));  
lastModifiedDate.setSearchValue(cal);    
custSearchBasic.setLastModifiedDate(lastModifiedDate);

SearchDateFieldOperator “ decides that the contact needs to be filtered after, before or on the date provided to searchdatefield. Operator can also be “Within” in which we will need to specify start as well as end date.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *