Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I did the following

1)Deleted a record in sfdc and then ran the query using ' ALL ROWS' keyword and i could see that as per the documentation that data from recycle bin is also retrieved with isdeleted=true

2)I deleted the record from recycle bin and now i observed that still i was able to retrieve it .

Can anybody aware why this happens ?

Also if i filter the records by date and use ALL ROWS will the date filter still apply?

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

Documentation around the Database.emptyRecycleBin (which essentially is what happens when you click the button in the Recycle Bin too) says "After records are deleted from the recycle bin using this call, they can be queried using queryAll() for some time. Typically this time is 24 hours, but may be shorter or longer."

(added after the comment about REST API:) Visibility of stuff in the Recycle Bin doesn't look like something we have control over. If you can somehow expose this function to your REST app (by wrapping a piece of Apex like here) you could "hard delete" your records. But even then they'll stay visible, you'll just guarantee receiving DMLException if anybody tries to undelete them.

And yes, you can mix filtering by date fields, isDeleted and ALL ROWS.

SELECT Id, isDeleted, LastModifiedBy.Name, LastModifiedDate FROM Account WHERE CreatedDate = TODAY ALL ROWS and for deleted records LastModifiedBy will mean who & when has deleted them while for "normal" ones it will be last update.

I must say I'm a bit confused. Please write up more about your actual requirements? Essentially - do you want to show items in recycle bin or not :)


Edit again ;)

Sounds like most natural cut for your situation was done by smart guys at SF already.

1 normal query that gets all creates & updates

SELECT (all the fields you need) FROM Obj WHERE LastModifiedDate >= :lastUpsertSync

And another! query for deletes (you need only basic info that item was deleted after all, no need to retrieve details, right?)

SELECT Id FROM Obj WHERE isDeleted = true AND LastModifiedDate >= :lastDeleteSync ALL ROWS

If you're afraid you'll hit heap size limits or count of rows - simply add something like ORDER BY LastModifiedDate ASC LIMIT 1000 clauses to both queries. Then whenever one of queries returns exactly 1000 you'll know there's risk you haven't retrieved full set. Then modify the variable that holds for example lastDeleteSync to value from last row and rerun the sync, ask user to hit the button again or whatever. Even better - use the queryLocator's id to retrieve next set of results (but before your session expires).

share|improve this answer
    
Ya thanks removed the FOR from qestion.I tried after one day also and it remained same .So worried that it will keep adding.Also my app logics planned wont allow me to use emptyRecycleBin.Thanks for your reply.Looking for some more answers from all –  Mohith Kumar Nov 4 '12 at 16:11
    
Thanks again.unfortunately my app is mobile app using IOS SDK uses objective C .So do we have any RestApi calls ? –  Mohith Kumar Nov 4 '12 at 16:33
    
App is designed for offline sync.I query for all records thats been modified or deleted or created after the last sync and indicate via a flag which is D for deleted,U for updated and C for created only after the last sync .I am afraid that if deleted records keep coming in output JSON then i will reach the 50000 query rows limit also may be i will reach heap size before that.Also once deleted from the salesforce we just delete in app and we expect no more undletes happen in browser .Anyways thanks for your help –  Mohith Kumar Nov 4 '12 at 17:05
    
Thanks for the reply.Can i not merge both queries here.Last Synced time will be same for upserts and deletes.I can reduce an SOQL .Thanks.Looking for more answers from rest of community and if i dont i will mark as ticked.Thanks –  Mohith Kumar Nov 5 '12 at 7:58
add comment

I have some problems with the empty Recycle Bin API function (using PHP toolkit).

It shows all Recycle Bin records even after I delete them all!

But in the salesforce UI it shows that Recycle Bin list is cleared. In my application I listed the deleted item (in Recycle Bin ) by condition 'IsDeleted=true'.

Any ideas how to avoid this situation?

share|improve this answer
2  
Hi John. I would really suggest you start a new Question. Answers are for answering existing questions. This question has been answered. Your question will get more visibility if you start a new question. Here's the link: salesforce.stackexchange.com/questions/ask –  Peter Jan 28 '13 at 16:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.