You need to sign in to do that
Don't have an account?
santhosh konathala 17
Hi friends I am new to this environment could you please help me how to fetch records from recycle bin which are deleted recently using Apex code?
list<account> a= new list<account>();
List<Account> acclist = [select id, name,Isdeleted from account limit 4];
for(account acc:acclist)
{
a.add(acc);
}
undelete a;
Above is my code getting error please help me where I was written wrong....
List<Account> acclist = [select id, name,Isdeleted from account limit 4];
for(account acc:acclist)
{
a.add(acc);
}
undelete a;
Above is my code getting error please help me where I was written wrong....
List<Account> acclist = [select id, name,Isdeleted from account where isDeleted = true ALL ROWS limit 4 ]);];
for(account acc:acclist)
{
a.add(acc);
}
undelete a;
Using All Rows you can fetch all records i.e. even deleted records. IsDeleted flag helps you to identify is that record is deleted or not.
Please mark this as best ans if helps!!
All Answers
List<Account> acclist = [select id, name,Isdeleted from account where isDeleted = true ALL ROWS limit 4 ]);];
for(account acc:acclist)
{
a.add(acc);
}
undelete a;
Using All Rows you can fetch all records i.e. even deleted records. IsDeleted flag helps you to identify is that record is deleted or not.
Please mark this as best ans if helps!!
If you want to use only the records which are available in Recyle bin, you need to use a WHERE condition of isDeleted = TRUE along with ALL ROWS.
list<account> a= new list<account>();
List<Account> acclist = [select id, name,Isdeleted from account WHERE isDeleted = TRUE limit 4 ALL ROWS];
for(account acc:acclist)
{
a.add(acc);
}
undelete a;
Hope it helps.
Now the above code works fine