如何使用api从Netsuite搜索工作订单记录?

时间:2013-09-11 07:23:00

标签: c# netsuite

我必须根据工作订单号从NetSuite获取工作订单记录,我可以使用已保存的搜索来执行此操作,但是如果没有它,我希望这样做,因为我没有在生产中创建另一个已保存的搜索记录。我的代码没有返回任何结果,但搜索成功。

这是我正在使用的代码:

        TransactionSearch ts = new TransactionSearch();
        TransactionSearchBasic tsb = new TransactionSearchBasic();

        // work order number
        SearchStringField sfTranId = new SearchStringField();
        sfTranId.@operator = SearchStringFieldOperator.@is;
        sfTranId.searchValue = workorder;
        sfTranId.operatorSpecified = true;

        // type
        SearchEnumMultiSelectField sfType = new SearchEnumMultiSelectField();
        sfType.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
        sfType.operatorSpecified = true;
        sfType.searchValue = new String[] {"_workOrder"};

        tsb.tranId = sfTranId;
        tsb.type = sfType;

        ts.basic = tsb;
        tsa3.criteria = ts;

        // perform the search
        SearchResult res = _service.search(ts);
        res.pageSizeSpecified = true;

        if (res.status.isSuccess)
        {
            SearchRow[] searchRows = res.searchRowList;
            if (searchRows != null && searchRows.Length >= 1)
            {
                TransactionSearchRow tranRow = (TransactionSearchRow)searchRows[0];
                if (tranRow.basic.internalId != null && tranRow.basic.internalId.Length > 0)
                {
                    woResult = tranRow.basic.internalId[0].searchValue.internalId;
                }                    
            }                
        }

1 个答案:

答案 0 :(得分:0)

我意识到自己的错误,基本搜索返回RecordList而不是SearchRowList。