热门从netsuite获取最后修改的贷项通知单记录

时间:2014-12-03 16:02:04

标签: java web-services netsuite

我正在使用Java和NetSuite webserivces来获取所有客户的最后修改的贷项凭证交易或退款交易,但没有任何类型的searchBasic类来执行此操作。如果有人在此之前完成它,请提供您的建议或绝对答案,因为我是netsuite的新手,我不知道所有的事情。

如果你知道余额而不是贷记通知单,那么它对我也有帮助。

1 个答案:

答案 0 :(得分:1)

public ArrayList<CreditMemo> searchRecentCreditMemos()
        throws Exception {
    TransactionSearch transactionsSearch = new TransactionSearch();
    TransactionSearchBasic transactionSearchBasic = new TransactionSearchBasic();
    CustomerSearchBasic custSearchBasic = new CustomerSearchBasic();

    Calendar startDate = Calendar.getInstance();
    startDate.add(Calendar.DAY_OF_MONTH, -1);
    Calendar endDate = Calendar.getInstance();

    // Create criteria
    com.netsuite.webservices.platform.core_2014_1.SearchDateField searchDateField = new com.netsuite.webservices.platform.core_2014_1.SearchDateField();
    searchDateField
            .setOperator(com.netsuite.webservices.platform.core_2014_1.types.SearchDateFieldOperator.within);
    searchDateField.setSearchValue(startDate);
    searchDateField.setSearchValue2(endDate);

    transactionSearchBasic.setLastModifiedDate(searchDateField);

    transactionsSearch.setBasic(transactionSearchBasic);
    transactionsSearch.setCustomerJoin(custSearchBasic);

    SearchResult result = port.search(transactionsSearch);
    ArrayList<CreditMemo> creditMemoList = new ArrayList<>();

    if (result.getStatus().isIsSuccess()) {
        RecordList recordList = result.getRecordList();
        Record[] records = recordList.getRecord();

        if (records != null && records.length != 0) {
            for (int i = 0; i < records.length; i++) {
                if (records[i] instanceof CreditMemo) {
                    CreditMemo creditMemo = (CreditMemo) records[i];
                    creditMemoList.add(creditMemo);
                }
            }
        }
    }

    return creditMemoList;
}