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
NHKNHK 

How to Query deleted Records? (Records in Recycle Bin)

Hi All,

 

I need to get the count of deleted records (record count in the Recycle Bin). How can i get this? I have searched in the forum and found that we can use ALL ROWS keyword to query Recycle Bin Records. But When i use this keyword to query the Count, i am getting the same count as that of the query with out the ALL ROWS keyword.

 

For Example: Both the below Queries are giving the same count.

 

select count() from Notification_Queue__c where ownerid = '00GF0000001K14E' ALL ROWS

select count() from Notification_Queue__c where ownerid = '00GF0000001K14E'

 

But I am sure that there are records in the Recycle Bin with the same OwnerId.

 

Any idea would be appreciated. Thanks in Advance.

 

NHKashyap

 

Puja_mfsiPuja_mfsi

Hi,

You need to add "ALL ROWS" at the end of query.

Yes I think there is no records in recycleBin.

 

 

 

souvik9086souvik9086

Hi,

 

Try this and let me know what happened

 

select count() from Notification_Queue__c where ownerid = '00GF0000001K14E' AND IsDeleted = true ALL ROWS

 

If this post solves your problem kindly mark it as solution. if this post is helpful please throw Kudos.

Thanks

 

NHKNHK

Hi Souvik,

 

The below Query is resulting in 0 count.

 

select count() from Notification_Queue__c where ownerid = '00GF0000001K14E' AND IsDeleted = true ALL ROWS.

 

select count() from Notification_Queue__c where ownerid = '00GF0000001K14E'  ALL ROWS. -->  count = 10674.

 

select count() from Notification_Queue__c where ownerid = '00GF0000001K14E'  --> Count = 10674

 

select count() from Notification_Queue__c where ownerid = '00GF0000001K14E' AND IsDeleted = true --> count = 0.

 

I am totally confused. Please help.

 

Best regards,

NHKashyap

NHKNHK

Hi Puja,

 

I have added ALL ROWS to the query i can see records are there in recycle bin with the same owner id (i mean if i undelete it, i can see the same ownerid).

 

Best regards,

NHKashyap

Puja_mfsiPuja_mfsi

Hi,

Query 1.   select count() from Notification_Queue__c where ownerid = '00GF0000001K14E' AND IsDeleted = true ALL ROWS

it means youselect only deleted records.

Query 2. select count() from Notification_Queue__c where ownerid = '00GF0000001K14E'  ALL ROWS.

It means you select all records( deleted as well as non deleted records)

Query 3. select count() from Notification_Queue__c where ownerid = '00GF0000001K14E'

it means you select only non -deleted records.

 

If the count of "Query 2" and "query 3" are same it means there is no records in recycle bin

And if the "Query 1" give 0 then you don't have any record in recycle bin or deleted.

 

Now tell me what is your requirement .

 

 

 

NHKNHK

Hi,

 

I am clear with that logic, but i have only one question. I can see there are records in the recycle bin with the same user as owner. So at that time, Query 2 and 3 should give different count. But it is giving the same count. ok, let me check again and will share if i found anything. Thank you for your reply.

 

Best regards,

NHKashyap