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

how to undelete record using soql query..?

Is any one help me how to undelete record using soql query..? 

I am using this query "Contact[] c = [select id from contact where isDeleted = true LIMIT 1000 ALL ROWS];
undelete c;"
When i use this query I am getting this error "System.DmlException: Undelete failed. First exception on row 0 with id 00390000019TLhkAAG; first error: UNDELETE_FAILED, Entity is not in the recycle bin: []".

Can any one help how to undelete records using soql query.?
Frédéric TrébuchetFrédéric Trébuchet
Your code is good.
You have to know that in certains circumstances, some records may respond to the query with "isDeleted = true" but can't be undeleted because physically not in the recycle bin.

Hope this helps,
Frédéric TrébuchetFrédéric Trébuchet

Does this answer help you solved your problem?
If so, mark the question as Solved and kindly select the best answer.