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
JayantJayant 

How to use QueryAll() API call in Apex ???

How  can I use the QueryAll() API call in an Apex Trigger ?

Is this possible ?

Is their any out-of-the-box class that provides an equivalent method to achieve this ???

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

all rows only works in apex, it does not work through the web servies api. (which is what those other tools use)

All Answers

Pradeep_NavatarPradeep_Navatar

In my opinion, there is no such method QueryAll in apex. Only 'database.query' exist in dynamic apex.Queryall().

 

Hope this helps.

ca_peterson_oldca_peterson_old

No.

 

But if you use a SOQL query inside of a for loop it will make calls to query() and queryMore() as needed up to the 10,000 row limit imposed by the apex govenor.

 

Something like:

 

List<Account> accounts = new List<Account>();

for(Account thisAccount:[SELECT id FROM Account]){

accounts.add(thisAccount);

}

 

This is as close as you're going to get in apex just due to the 10k row limit.

JayantJayant

OK,  my requirement is to get a count of activities ( Tasks and Events) including those which are archived.

As far as I know we may query archived records only using a queryAll() API call,  I can not find any static method that mimics this behavior in Apex and by default archived records are always excluded from a SOQL query point of view.

 

So I am searching for a method that has the same functionality as queryAll() API call.

 

I am aware of Query() and QueryMore(), but here I am interested in QueryAll().

 

Thanks.

 

 

SuperfellSuperfell

add all rows to the query, e.g.

 

List<Account> acc = [select id,name from account all rows];

JayantJayant

Hi Simon,

 

I had tried this as well but in Force.com IDE and Data Loader (but got the error, ALL ROWS not allowed in this context).

My query looked like this -

Select t.Id, t.AccountId, t.isDeleted, t.isArchived from Task t ALL ROWS

I am currently not having access to my Org due to IP restrictions, may be I would try this in Apex Trigger on monday and let you know the results.

 

Thanks a lot.

SuperfellSuperfell

all rows only works in apex, it does not work through the web servies api. (which is what those other tools use)

This was selected as the best answer
JayantJayant

OK.

Thanks a lot Simon.

 

Actually I have a habit of running all queries in Force.com IDE first, before using them in Apex.

 

OK, I have one more query and I guess your opinion might be useful on that.

 

Actually I was seeing more tasks in GUI than in SFDC schema's Task table. So I raised a case with SFDC for this and the support personnel got back to me that actually I am also seeing the archived tasks in GUI, and my doubt is "How can I view archived tasks in GUI ?" I guess they are not visible their. I wrote back to the support person but didn't receive any reply.

 

Here I am not using the View All button, neither is my page overridden, it's simple standard SFDC Account detail page's related list. Also I am not seeing the Print layout, it's just the normal related list that appears by default.

 

Would appreciate your opinion on the same.

 

Thanks a lot once again, I was really looking to sort this ALL ROWS stuff.

Chirag MehtaChirag Mehta

Tried following options, but I'm not able to get deleted records. I can see deleted records when I query using workbench or eclipse schema. 

 

List<EntitySubscription> esList = [SELECT id from EntitySubscription where IsDeleted=true ALL ROWS];
System.Debug(esList);

 

List<EntitySubscription> esList = Database.query('SELECT id from EntitySubscription where IsDeleted=true ALL ROWS');
System.Debug(esList);