Question

We've successfully migrated our v2 QBO to v3 and after that on the production we got an issue from one of our customers. They have over 100 their customers in QBO account. And they want to copy them into our application. We implemented an import like this:

    DataService service = getDataService(owner);  // obtain DataService via Access Keys
    List<com.intuit.ipp.data.Customer> customers = 
         service.findAll(new com.intuit.ipp.data.Customer()); 
    for (com.intuit.ipp.data.Customer customer : customers) {
        createCustomer(customer, owner);  // this is our internal method to create
    }

As mentioned in Class Library Reference - method findAll is a

    Method to retrieve all records for the given entity.

But our customer is getting only first 100 entities (Customer's) from his QBO v3 account. And if he do the same import operation - he will get the same first 100 entities again. This method doesn't allow any pagination options.

So the question is, how to get all of the entities?

Was it helpful?

Solution

You should use Query endpoint with page filters.

The following query gets customers 1 - 10:

String query = select($(customer)).skip(0).take(10).generate();

Output - SELECT * FROM Customer STARTPOSITION 1 MAXRESULTS 10

The following query gets customers 21 - 25:

String query = select($(customer)).skip(20).take(10).generate();

Ref - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0201_ipp_java_devkit_3.0/0011_query_filters#Pagination

finally

QueryResult queryResult = service.executeQuery(query);

Thanks

OTHER TIPS

To fetch all of customers for a specified business, first you need to get their count, and then, as mentioned at the previous answer, get the customers by "take" method:

        Integer customersTotal = service.executeQuery(selectCount(_customer).generate()).getTotalCount();
        QueryResult queryResult = service.executeQuery(select($(_customer)).skip(0).take(customersTotal).generate());
        List<? extends IEntity> entities = queryResult.getEntities();
        for (IEntity entity : entities) {
            if (entity instanceof com.intuit.ipp.data.Customer) {
                createCustomer((com.intuit.ipp.data.Customer) entity, owner);
            }
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top