2014-12-03 27 views
0

我正在使用Java和NetSuite webserivces獲取最後修改的貸項憑證交易或所有客戶的退款交易,但沒有任何一種searchBasic類來執行此操作。如果任何人之前完成它,請提供您的建議或絕對答案,因爲我是netsuite的新手,我不知道所有的事情。很熱從netsuite獲得最後修改的貸項憑證記錄

如果你知道餘額而不是貸項憑證,那麼它也會對我有幫助。

回答

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; 
}