# QuickBooks Data Extraction Queries

## QuickBooks Queries

Knowledge of QuickBooks and QuickBooksXML is required for mapping and creating a process for integration with QuickBooks.

QuickBooks Desktop" adapter/connector provides interfaces for:

* Reader: reading from QuickBooks with an SQL like query.
* Writer: writing into QuickBooks.
* Metadata query: navigating through QuickBooks objects.

You can build the queries of QuickBooks or QuickBooks Desktop Adapter from the Reader Section of the Process Definition. You can build queries similar to SQL, which includes the straightforward query.

**Reader Query Examples:**

**Customer Query**

The following is a query to extract all Customers in batches of 100 that have been changed since the last successful run of the process.

{% code overflow="wrap" %}

```
Select * from Customer where Customer.MaxReturned=100 and Customer.FromModifiedDate=$last_success_run
```

{% endcode %}

* MaxReturned suggests how many records are to be retrieved from QuickBooks.
* FromModifiedDate suggests the filter for selecting Customers that are edited or created after the previous sync run.
* $last\_success\_run is a process-specific variable that gets set up whenever the ETL process is successfully completed.

{% hint style="info" %}
Refer the filters from the QuickBooksXML. This is available in DBSync On-Premise version under this DBSync2\src\www\WEB-INF\conf folder. The XML Structures of all QuickBooks Objects are specified in this file.
{% endhint %}

**ItemService Query**

The following is a query to extract all ItemService in batches of 100 that have been changed since the last successful run of the process.

{% code overflow="wrap" %}

```
Select * from ItemService where ItemService.MaxReturned=100 and ItemService.FromModifiedDate=$last_success_run
```

{% endcode %}

Other items - such as ItemNonInventory, ItemInventory, and ItemDiscount - are not supported in QuickBooks Online Edition.

**Complex query with a join**

{% code overflow="wrap" %}

```
select * from Invoice,Customer where Invoice.MaxReturned=100 and Invoice.ModifiedDateRangeFilter.FromModifiedDate=$last_success_run
and Invoice.IncludeLineItems=true and Invoice.OwnerID=0 join on Invoice.CustomerRef.FullName=Customer.FullName
```

{% endcode %}

The above query joins Invoice and Customer QuickBooksXML responses into one XML. As a result, the transformation engine can avoid multiple processes. This is done to optimize data flow to and from QuickBooks.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mydbsync.com/cloud-workflow/tutorials/salesforce-and-quickbooks/quickbooks-data-extraction-queries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
