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
vijaya Pepakayalavijaya Pepakayala 

Can Any one help from the undelete operation iam trying 3 time to undelete only single record its working fine but when iam trying know the difference with AllRows and without Allrows to the undelete operationd

vijaya Pepakayalavijaya Pepakayala
but it showing  entity is not there in Recyle bin
 
SwethaSwetha (Salesforce Developers) 
HI Vijay,

The ALL ROWS keyword queries all rows for both top level and aggregate relationships, including deleted records and archived activities.

To identify deleted records, including records deleted as a result of a merge, use the ALL ROWS parameters with a SOQL query.

Reference

If this information helps, please mark the answer as best. Thank you
vijaya Pepakayalavijaya Pepakayala
thank you Swetha but AM Already tried that
public static void test_Method(){
        List<Account> testacc = [Select id, Name, AnnualRevenue,Industry from Account where Industry = 'Electronics' ALL ROWS];
        undelete testacc;
        System.debug('Accounts after undeleting'+testacc);
        System.debug('Accounts after size undeleting'+testacc.size());
    }
its showing undelete failed  entity is not in the Recycle bin


 
Shri RajShri Raj
The allRows parameter in the undelete method determines whether all records in the specified list of sObjects are to be undeleted, or only the records that have not been previously undeleted.
When you pass allRows=true to the undelete method, all records in the specified list will be undeleted, regardless of whether they have been previously undeleted or not.
When you pass allRows=false (or omit the parameter entirely), only the records that have not been previously undeleted will be undeleted.
So, when you are trying to undelete only single record, you can use the allRows=false or you can simply omit it. But when you are trying to undelete all records, you need to use allRows=true to undelete all records.
vijaya Pepakayalavijaya Pepakayala
 List<Account>lisacc = [Select id, Name, AnnualRevenue,Industry from Account where Industry = 'Electronics' ALL ROWS = false];
        undelete lisacc



Still it was showingUser-added image


 
vijaya Pepakayalavijaya Pepakayala
List<Account> lisacc = [Select id, Name from Account where Industry = 'Electronics' ALL ROWS];
              undelete lisacc;

Line: 6, Column: 1
System.DmlException: Undelete failed. First exception on row 4 with id 001Dn00000D3uOpIAJ; first error: UNDELETE_FAILED, Entity is not in the recycle bin: []
User-added image