function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anschoeweGanschoeweG 

How to query archived Tasks using Bulk Api

I'm trying to retrieve all Tasks in our Salesforce instance, including those that were archived more than 12 months ago. Since we have over 3 million records, I decided to try the bulk api. It seemed promising until I ran into this error:

MALFORMED_QUERY: ALL ROWS not allowed in this context

Does bulk-api not support querying for archived tasks? I believe you simply include 'ALL ROWS' at the end of your SOQL query to retrieve deleted and archived records. Is there another way to do this using the bulk api? If not, this seems like a huge limitation. Archived tasks seem like a prime candidate for the bulk api.

Here's an example of one of my queries:

Select Id from Task Where CreatedDate >= 2013-01-01T00:00:00z and CreatedDate < 2013-03-01T00:00:00z ORDER BY Id ASC ALL ROWS

In the spirit of full discloser, I posted this on StackExchange (http://salesforce.stackexchange.com/questions/27326/how-to-query-archived-tasks-using-bulk-api)but we haven't yet been able to find  a dinitive solution.  I thought this mighte be a wider audience that could help.  Perhaps Bulk API is more geared towrads data uploads to Salesforce instead of querying.  I would love it if someone could tell me if running these queries via multiple SOQL queries (queryAll()) would yield similar performance.

Any help is appreciated, Andrew
Ashish_SFDCAshish_SFDC
Hi Andrew, 


Try using SOAP API, 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_queryall.htm

Or 

You can use the queryAll() function instead of the simple query() function for the desired result in this context.

http://raydehler.com/cloud/clod/how-to-select-archived-tasks-and-events-in-soql.html

See a similar thread, 

https://developer.salesforce.com/forums?id=906F00000008yNXIAY

https://developer.salesforce.com/forums?id=906F00000008uzkIAA


Regards,
Ashish
anschoeweGanschoeweG
Thanks. I'm aware of how to do this with SOQL within the SOAP API. But after a brief Twitter exchange with a Salesforce employee, it was confirmed that there is no queryAll() like feature in the bulk API. In addition, I've learned there are really no performer benefits to using bulk API for querying -other than a longer timeout value. Andrew
Rohan JainRohan Jain
On the Bulk Query documentation they sa y - 

"Bulk API query supports both query and queryAll operations." 
https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_using_bulk_query.htm

Any idea how to perform queryAll using Bulk Query?