NetSuite-通过复杂查询搜索客户

时间:2019-07-07 09:46:16

标签: c# netsuite

我正在尝试搜索包含以下字段的客户:电子邮件 firstName lastName ID。

它们之间必须为 OR 条件。

例如

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

如何在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;
}

我希望找到以下字段之一包含以下搜索文字的客户: 电子邮件,fName,lName,Id。

1 个答案:

答案 0 :(得分:3)

根据NetSuite SuiteAnswers id 31408

Web服务>搜索>如何为一个值或另一个值设置字段过滤器

当前,Web Service搜索不支持表达式。 为了搜索字段在哪里是一个值或另一个。有必要提交两个搜索请求,然后将结果合并到应用程序代码中。