+ Start a Discussion
Deepak PansariDeepak Pansari 

RecycleBin help required...

Hi All,


I have a custom object  , if user is delete a record for that object it goes to Recycle bin and user will able to restore it.


I want to prevent user to restoring the record fron recycle bin.


Can some one help me ?


- Deepak 


Best Answer chosen by Admin (Salesforce Developers) 

The only method that works today is to forcefully prevent it from being restored. You can do this in a trigger:


trigger killUndeleteOnObject on CustomObject (after undelete) {
  for(CustomObject o:Trigger.new)
    o.addError('You shall not pass!');

The error message won't display (hence, my JRR Tolkien quote), but the effect will be the same. The user will receive an generic message stating that the record can not be undeleted.