Search code examples
javanetsuitesuitetalk

Netsuite, how to search for Open Vendor Bills (Transactions)


Would seem to be simple but as so often with netsuite, it's painful. This is what i have so far:

        TransactionSearch invoiceSearch = new TransactionSearch();        

        TransactionSearchBasic invoiceSearchBasic = new TransactionSearchBasic();

        SearchEnumMultiSelectField criteria = new SearchEnumMultiSelectField();                       

        criteria.setOperator(SearchEnumMultiSelectFieldOperator.ANY_OF);
        String[] statuses = new String[] { TransactionStatus.BILL_OPEN.toString() };

        stats.getSearchValue().addAll(Arrays.asList(statuses));

        invoiceSearchBasic.setStatus(stats);

If i comment out the invoiceSearchBasic.setStatus line I get all the transactions fine (including the ones i want with a staus of "Open") but when it's there I get nothing. Needless to say changing TransactionStatus.BILL_OPEN.toString() to "Open" doesn't work either, that would be far too easy!


Solution

  • Ok I've resolved it. For anyone else, this is the problem:

    from the TransactionStatus enumeration:

    @XmlEnumValue("_billOpen")
    BILL_OPEN("_billOpen")
    

    which when you log the toString value it gives BILL_OPEN (not _billOpen)

    but it's _billOpen we need!

    solution:

    SearchEnumMultiSelectField criteria = new SearchEnumMultiSelectField();
    criteria.setOperator(SearchEnumMultiSelectFieldOperator.ANY_OF);
    String[] statuses = new String[] { "_billOpen" };
    criteria.getSearchValue().addAll(Arrays.asList(statuses));