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
Vishal Gupta 111Vishal Gupta 111 

Why we can't use trigger.old in after undelete trigger event?

Best Answer chosen by Vishal Gupta 111
Ajay K DubediAjay K Dubedi
Hi Vishal,

You need to understand:
The after undelete trigger event only works with recovered records—that is, records that were deleted and then recovered from the Recycle Bin through the undelete DML statement. These are also called undeleted record.
Undelete operation in the trigger will be fired, if you are restoring deleted record from the recycle bin.
Example. If you deleted an account record, then it will be moved to recycle bin, if you restore the deleted account record from recycle bin,
then undelete event in account object will get triggered.

Trigger. New will hold the new value of the record, you can't use trigger.old in after undelete trigger event. 
The undelete is like the insert. Before the undelete operation the record does not exist on your database.

Hope you this explanation will help you.If you like this explanation mark it as best answer so others get help from this.

Thanks.
Ajay Dubedi

All Answers

ohio jimohio jim
Download VidMate (https://vidmate.tech/) - HD video downloader 3.5301. Fast and easily download YouTube music and HD videos. Vidmate is one of the best known applications ...
Bhargavi TunuguntlaBhargavi Tunuguntla
Hi  Vishal 

​Undelete operation in trigger will fired, if you are restoring deleted record from the recycle bin. Example. If you deleted an account record, then it will be moved to recycle bin,if you restore the deleted account record from recycle bin, then undelete event in account object will get triggered.

Trigger.New will holds the new value of the record, you can't use trigger.old in after undelete trigger event. To get more details, please check this link

 https://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_triggers_recovered_records.htm|StartTopic=Content%2Fapex_triggers_recovered_records.htm|SkinName=webhelp January 28, 2015 


The explanation is every clear . I refered this from: 

https://developer.salesforce.com/forums/?id=906F0000000AwffIAC



Hope this Helps.

Thanks
Bhargavi.


·
 
Ajay K DubediAjay K Dubedi
Hi Vishal,

You need to understand:
The after undelete trigger event only works with recovered records—that is, records that were deleted and then recovered from the Recycle Bin through the undelete DML statement. These are also called undeleted record.
Undelete operation in the trigger will be fired, if you are restoring deleted record from the recycle bin.
Example. If you deleted an account record, then it will be moved to recycle bin, if you restore the deleted account record from recycle bin,
then undelete event in account object will get triggered.

Trigger. New will hold the new value of the record, you can't use trigger.old in after undelete trigger event. 
The undelete is like the insert. Before the undelete operation the record does not exist on your database.

Hope you this explanation will help you.If you like this explanation mark it as best answer so others get help from this.

Thanks.
Ajay Dubedi
This was selected as the best answer