2

知道为什么下面的代码会为其状态返回错误(失败)吗?

    private SearchResult getTxns()
    {
        TransactionSearchAdvanced tsa = new TransactionSearchAdvanced();

        tsa.columns = new TransactionSearchRow();

        tsa.columns.basic = new TransactionSearchRowBasic();
        tsa.columns.basic.tranId = new SearchColumnStringField[] { new SearchColumnStringField() };

        tsa.criteria = new TransactionSearch();
        tsa.criteria.basic = new TransactionSearchBasic();

        tsa.criteria.basic.mainLine = new SearchBooleanField();
        tsa.criteria.basic.mainLine.searchValue = true;
        tsa.criteria.basic.mainLine.searchValueSpecified = true;

        tsa.criteria.basic.type = new SearchEnumMultiSelectField();
        tsa.criteria.basic.type.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
        tsa.criteria.basic.type.operatorSpecified = true;
        tsa.criteria.basic.type.searchValue = new string[] { "_salesOrder" };

        tsa.criteria.basic.otherRefNum = new SearchTextNumberField();
        tsa.criteria.basic.otherRefNum.@operator = SearchTextNumberFieldOperator.equalTo;
        tsa.criteria.basic.type.operatorSpecified = true;
        tsa.criteria.basic.type.searchValue = new string[] { "BBnB 1001" };

        SearchResult sr = _service.search(tsa);

        return sr;
    }

以下是结果中返回的错误。

状态代码: INVALID_SEARCH_OPERATOR
状态消息:您需要提供有效的搜索字段运算符。

但是,当我进行搜索时,此运算符会出现在 NetSuite UI 中。此外,我在此处的 NetSuite 文档中找到了它。

我将 v2013_1_0 用于 wsdl 的 web 服务版本。

解决方案

在最后一段代码中找到了解决方案。试图设置 otherRefNum 并引用 Type。这是更正后的代码。

    private SearchResult getTxns()
    {
        TransactionSearchAdvanced tsa = new TransactionSearchAdvanced();

        tsa.columns = new TransactionSearchRow();

        tsa.columns.basic = new TransactionSearchRowBasic();
        tsa.columns.basic.tranId = new SearchColumnStringField[] { new SearchColumnStringField() };

        tsa.criteria = new TransactionSearch();
        tsa.criteria.basic = new TransactionSearchBasic();

        tsa.criteria.basic.mainLine = new SearchBooleanField();
        tsa.criteria.basic.mainLine.searchValue = true;
        tsa.criteria.basic.mainLine.searchValueSpecified = true;

        tsa.criteria.basic.type = new SearchEnumMultiSelectField();
        tsa.criteria.basic.type.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
        tsa.criteria.basic.type.operatorSpecified = true;
        tsa.criteria.basic.type.searchValue = new string[] { "_salesOrder" };

        tsa.criteria.basic.otherRefNum = new SearchTextNumberField();
        tsa.criteria.basic.otherRefNum.@operator = SearchTextNumberFieldOperator.equalTo;
        tsa.criteria.basic.otherRefNum.operatorSpecified = true;
        tsa.criteria.basic.otherRefNum.searchValue = "BBnB 1001";

        SearchResult sr = _service.search(tsa);

        return sr;
    }
4

1 回答 1

1

问题出在您的SearchEnumMultiSelectField运营商身上。equalto不是此过滤器的有效运算符;您将需要anyOf改用。

-- 编辑 - 改编自原始评论 --

ASearchTextNumberField不接受字符串数组。而是尝试tsa.criteria.basic.otherRefNum.searchValue = "BBnB 1001";

于 2013-08-20T23:45:35.430 回答