4

I am trying to search customers who contain these fields : email or firstName or lastName or id.

must be an OR condition between of them.

for example

var freeText = "shomeone@gmai";
var customers = SearchForCustomersWhoContainsThisData(freeText)

how can i build this query in c#?

public List<Customer> SearchForCustomersWhoContainsThisData(string search_text)
{
    CustomerSearch custSearch = new CustomerSearch();

    SearchStringField searchField = new SearchStringField();
    searchField.@operator = SearchStringFieldOperator.contains;
    searchField.operatorSpecified = true;
    searchField.searchValue = search_text;
    CustomerSearchBasic custBasic1 = new CustomerSearchBasic();
    custBasic1.firstName = searchField;

    CustomerSearchBasic custBasic2 = new CustomerSearchBasic();
    custBasic2.lastName = searchField;

    custSearch.basic = custBasic1;
    //custSearch.basic = custBasic2; how to add this with or between

    // Search for the customer entity who contains this text
    SearchResult response = _crmNetSuitService.search(custSearch);
    var searchResults = response.recordList.Select(t => (Customer)t).ToList();

    return searchResults;
}

I expect to find customers who one of these fields contains this search-text: email, fName, lName, Id.

1 Answers1

3

As per NetSuite SuiteAnswers id 31408

Web Services > Search > How to set a field filter for one value OR another value

Currently, expressions are not supported via Web Services searches. In order to Search where a field is one value or another. It is necessary to submit two search requests, then merge the results in the application code.

vVinceth
  • 905
  • 5
  • 7