如何从Netsuite TransactionSearchAdvanced获取信用卡备忘录数据?

时间:2015-07-02 04:19:12

标签: c# netsuite

我是Netsuite API的新手。

我试图从TransactionSearchAdvanced获取Credit Memo数据(发票或供应商付款)。

这是我的代码:

public void GetCreditList()
    {

        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[] { "_creditMemo" };

        this.login(true);
        SearchResult response = _service.search(tsa);

        // Process response
        if (response.status.isSuccess)
        {
            if (response.totalRecords > 0)
            {
                for (int i = 1; i <= response.totalPages; i++)
                {
                    processCreditMemoSearchResponse(response);
                }
            }
            else
            {
                _out.info("\nNothing found.");
            }
        }
        else
        {
            //_out.error(getStatusDetails(response.status));
        }

        Console.ReadLine();

    }


private void processCreditMemoSearchResponse(SearchResult response)
    {
        _out.info("\nThe search() operation for customers was run successfully.");
        _out.info("\n  Total Records = " + response.totalRecords);
        _out.info("  Total Pages = " + response.totalPages);
        _out.info("  Page Size = " + response.pageSize);
        _out.info("  Current Page Index = " + response.pageIndex);

        //Record[] records = response.recordList;

        SearchRow[] records = response.searchRowList;

        CreditMemo creditMemo;
        for (int i = 0, j = (response.pageIndex - 1) * _pageSize; i < records.Length; i++, j++)
        {
            creditMemo = (CreditMemo)records[i];
            _out.info(
                "\n  Record[" + j + "]: " +
                "\n    internalId=" + creditMemo.internalId);
        }
    }

我得到了错误&#34;无法将SearchRow转换为CreditMemo&#34;

我不知道接下来要做什么。

任何提示都很感激!! 谢谢!

1 个答案:

答案 0 :(得分:0)

我找到了自己的解决方案!

public void GetInvoiceList()
    {

        TransactionSearch transactionsSearch = new TransactionSearch();
        TransactionSearchBasic transactionSearchBasic = new TransactionSearchBasic();

        transactionSearchBasic.type = new SearchEnumMultiSelectField();
        transactionSearchBasic.type.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
        transactionSearchBasic.type.operatorSpecified = true;
        transactionSearchBasic.type.searchValue = new string[] { "_invoice" };

        transactionsSearch.basic = transactionSearchBasic;

        this.login(true);

        SearchResult result = _service.search(transactionsSearch);
        List<Invoice> invoiceList = new List<Invoice>();

        if (result.status.isSuccess)
        {
            //RecordList recordList = result.recordList;
            Record[] records = result.recordList;

            if (records != null && records.Length != 0)
            {
                for (int i = 0; i < records.Length; i++)
                {
                    Invoice invoice = (Invoice)records[i];
                    invoiceList.Add(invoice);
                }
            }
        }


        Console.ReadLine();

    }