Search code examples
quickbooksquickbooks-online

How to filter for a object wiith a "value" and "name" in QBO api?


It seems like the API won't permit a query filter of the form:

SELECT * FROM purchaseorder WHERE APAccountRef.value='33'

In the case of purchase orders, it seems to mean that I need to bring down every purchase order to my server and scan for the account I need which is highly suboptimal. Is there some other syntax for querying against the many attributes which have been encoded like

{
  "APAccountRef": {
    "value": "33",
    "name": "Accounts Payable (A/P)"
  }
}

with just a name and value attribute?


Solution

  • If you refer to the QuickBooks Documentation, it gives you a list of all fields and a list of fields that are filterable. Your query is using a field (AccountRef.value='39') that does not exist as part of PurchaseOrder.

    The correct field is:

    APAccountRef: ReferenceType

    Specifies to which AP account the bill is credited.

    So your query should be:

    SELECT * FROM purchaseorder WHERE APAccountRef = '39'